strong_migrations 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +3 -1
- data/lib/generators/strong_migrations/install_generator.rb +15 -1
- data/lib/generators/strong_migrations/templates/initializer.rb.tt +6 -3
- data/lib/strong_migrations/safe_methods.rb +2 -2
- data/lib/strong_migrations/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd2b26a8cb5d3577ffaad3878ff961dec2bc6cb55c51897b2681febbf8f0b10
|
4
|
+
data.tar.gz: b48c9ff1050345351a9f938c6dd6dc8530fbc4842e0fc3c60702287fa3fb825c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bc2817b7878c3041442e4e4607db55b2861e7cba16220e635ee28a4b9ebd6dbd0a7ab16033555fa51f4f98601fe0eda198fa91e3030dfff63839c7cdc9aa028
|
7
|
+
data.tar.gz: 254e72cd2ce295759819f05cde920cf4c3ea9ae0d45af9f21d6ac11d55549d0d3544f97f511dc5b1dc0cf44c03c25af4208e4ab4f317449d9aabea90cd485b99
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -583,7 +583,9 @@ end
|
|
583
583
|
|
584
584
|
Certain methods like `execute` and `change_table` cannot be inspected and are prevented from running by default. Make sure what you’re doing is really safe and use this pattern.
|
585
585
|
|
586
|
-
## Safe by Default
|
586
|
+
## Safe by Default
|
587
|
+
|
588
|
+
*Experimental*
|
587
589
|
|
588
590
|
Make operations safe by default.
|
589
591
|
|
@@ -13,8 +13,14 @@ module StrongMigrations
|
|
13
13
|
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
14
|
end
|
15
15
|
|
16
|
+
def pgbouncer_message
|
17
|
+
if postgresql?
|
18
|
+
"\n# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
16
22
|
def target_version
|
17
|
-
case
|
23
|
+
case adapter
|
18
24
|
when /mysql/
|
19
25
|
# could try to connect to database and check for MariaDB
|
20
26
|
# but this should be fine
|
@@ -23,6 +29,14 @@ module StrongMigrations
|
|
23
29
|
"10"
|
24
30
|
end
|
25
31
|
end
|
32
|
+
|
33
|
+
def adapter
|
34
|
+
ActiveRecord::Base.connection_config[:adapter].to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def postgresql?
|
38
|
+
adapter =~ /postg/
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
28
42
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# Mark existing migrations as safe
|
2
2
|
StrongMigrations.start_after = <%= start_after %>
|
3
3
|
|
4
|
-
# Set timeouts for migrations
|
5
|
-
# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user
|
4
|
+
# Set timeouts for migrations<%= pgbouncer_message %>
|
6
5
|
StrongMigrations.lock_timeout = 10.seconds
|
7
6
|
StrongMigrations.statement_timeout = 1.hour
|
8
7
|
|
@@ -19,4 +18,8 @@ StrongMigrations.auto_analyze = true
|
|
19
18
|
# if method == :add_index && args[0].to_s == "users"
|
20
19
|
# stop! "No more indexes on the users table"
|
21
20
|
# end
|
22
|
-
# end
|
21
|
+
# end<% if postgresql? %>
|
22
|
+
|
23
|
+
# Make some operations safe by default
|
24
|
+
# See https://github.com/ankane/strong_migrations#safe-by-default
|
25
|
+
# StrongMigrations.safe_by_default = true<% end %>
|
@@ -7,12 +7,12 @@ module StrongMigrations
|
|
7
7
|
# TODO check if invalid index with expected name exists and remove if needed
|
8
8
|
def safe_add_index(table, columns, options)
|
9
9
|
disable_transaction
|
10
|
-
@migration.add_index(table, columns, options.merge(algorithm: :concurrently))
|
10
|
+
@migration.add_index(table, columns, **options.merge(algorithm: :concurrently))
|
11
11
|
end
|
12
12
|
|
13
13
|
def safe_remove_index(table, options)
|
14
14
|
disable_transaction
|
15
|
-
@migration.remove_index(table, options.merge(algorithm: :concurrently))
|
15
|
+
@migration.remove_index(table, **options.merge(algorithm: :concurrently))
|
16
16
|
end
|
17
17
|
|
18
18
|
def safe_add_reference(table, reference, options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strong_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
|
-
rubygems_version: 3.1
|
141
|
+
rubygems_version: 3.2.0.rc.1
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Catch unsafe migrations in development
|