strong_migrations 1.6.0 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23737504a1d3beb08bf2412b161b8e59a8a620b4f4d993f11fe931e7f1772452
4
- data.tar.gz: 993dc5f9d78cba148540a22772c18ed115ea6ae8075dd209cc3a869cc2a647a4
3
+ metadata.gz: 0a79294494eac7a9d8f36b3ec1c4c37dc11b2f1e5dccb4215333f55247acba4c
4
+ data.tar.gz: 7e9c2d8adc3cfb9cd1c3af33c001b38093260062b2278ae363e536c3a1d52cbb
5
5
  SHA512:
6
- metadata.gz: e906dc1c79d12a72a7d0e6fb4ca87319095d3b0a39f2da1dbd08b453d19e3215892745c86f80bf9ea26bbf07173d87022aab21b424a881f24744b65396fcd9bc
7
- data.tar.gz: 56a0dadcb236f09a1a7d5450456ae343ac8cb6662b65f983c28b4268edad6e7cbecfa47c86ebb0d1da72dcc1b305e7196521811a48838c25beb1119846a2b928
6
+ metadata.gz: 6d2a9758873a3a40c7968ca15a9d801821afbe426ee7bad43ee1b580ec4097a858c56722c22d7d9c04b7c5f83089fb17317036431016703b6148bfbff8b3cd7b
7
+ data.tar.gz: e710254af69bb5ac7d48955aa01a4dca5268c071d4a84904798f0a80e7caa9e5bf5cdd9902af9512fd23290233a1e757379ba09db6327dc8b910a7ca4e318803
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 1.6.2 (2023-09-13)
2
+
3
+ - Fixed foreign key options with `add_reference` and `safe_by_default`
4
+ - Fixed `safety_assured` with `revert`
5
+
6
+ ## 1.6.1 (2023-08-09)
7
+
8
+ - Fixed `safety_assured` for custom checks with `safe_by_default`
9
+
1
10
  ## 1.6.0 (2023-07-22)
2
11
 
3
12
  - Added check for `change_column_default`
@@ -5,22 +5,25 @@ module StrongMigrations
5
5
 
6
6
  attr_accessor :direction, :transaction_disabled, :timeouts_set
7
7
 
8
+ class << self
9
+ attr_accessor :safe
10
+ end
11
+
8
12
  def initialize(migration)
9
13
  @migration = migration
10
14
  @new_tables = []
11
15
  @new_columns = []
12
- @safe = false
13
16
  @timeouts_set = false
14
17
  @committed = false
15
18
  end
16
19
 
17
- def safety_assured
18
- previous_value = @safe
20
+ def self.safety_assured
21
+ previous_value = safe
19
22
  begin
20
- @safe = true
23
+ self.safe = true
21
24
  yield
22
25
  ensure
23
- @safe = previous_value
26
+ self.safe = previous_value
24
27
  end
25
28
  end
26
29
 
@@ -78,9 +81,11 @@ module StrongMigrations
78
81
  @committed = true
79
82
  end
80
83
 
81
- # custom checks
82
- StrongMigrations.checks.each do |check|
83
- @migration.instance_exec(method, args, &check)
84
+ if !safe?
85
+ # custom checks
86
+ StrongMigrations.checks.each do |check|
87
+ @migration.instance_exec(method, args, &check)
88
+ end
84
89
  end
85
90
  end
86
91
 
@@ -158,7 +163,7 @@ module StrongMigrations
158
163
  end
159
164
 
160
165
  def safe?
161
- @safe || ENV["SAFETY_ASSURED"] || (direction == :down && !StrongMigrations.check_down) || version_safe?
166
+ self.class.safe || ENV["SAFETY_ASSURED"] || (direction == :down && !StrongMigrations.check_down) || version_safe?
162
167
  end
163
168
 
164
169
  def version_safe?
@@ -21,7 +21,7 @@ module StrongMigrations
21
21
  ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
22
22
 
23
23
  def safety_assured
24
- strong_migrations_checker.safety_assured do
24
+ strong_migrations_checker.class.safety_assured do
25
25
  yield
26
26
  end
27
27
  end
@@ -30,10 +30,11 @@ module StrongMigrations
30
30
  (ActiveRecord::Base.pluralize_table_names ? reference.to_s.pluralize : reference).to_sym
31
31
  end
32
32
 
33
+ foreign_key_opts = foreign_key.is_a?(Hash) ? foreign_key.except(:to_table) : {}
33
34
  if reference
34
- @migration.add_foreign_key(table, name, column: "#{reference}_id")
35
+ @migration.add_foreign_key(table, name, column: "#{reference}_id", **foreign_key_opts)
35
36
  else
36
- @migration.add_foreign_key(table, name)
37
+ @migration.add_foreign_key(table, name, **foreign_key_opts)
37
38
  end
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.2"
3
3
  end
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: 1.6.0
4
+ version: 1.6.2
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: 2023-07-22 00:00:00.000000000 Z
13
+ date: 2023-09-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord