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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/strong_migrations/checker.rb +14 -9
- data/lib/strong_migrations/migration.rb +1 -1
- data/lib/strong_migrations/safe_methods.rb +3 -2
- data/lib/strong_migrations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a79294494eac7a9d8f36b3ec1c4c37dc11b2f1e5dccb4215333f55247acba4c
|
4
|
+
data.tar.gz: 7e9c2d8adc3cfb9cd1c3af33c001b38093260062b2278ae363e536c3a1d52cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
20
|
+
def self.safety_assured
|
21
|
+
previous_value = safe
|
19
22
|
begin
|
20
|
-
|
23
|
+
self.safe = true
|
21
24
|
yield
|
22
25
|
ensure
|
23
|
-
|
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
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
166
|
+
self.class.safe || ENV["SAFETY_ASSURED"] || (direction == :down && !StrongMigrations.check_down) || version_safe?
|
162
167
|
end
|
163
168
|
|
164
169
|
def version_safe?
|
@@ -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
|
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.
|
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-
|
13
|
+
date: 2023-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|