alterity 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/alterity.rb +2 -2
- data/lib/alterity/version.rb +1 -1
- data/spec/alterity_spec.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af06f20537df45280990abc9fd8c2235741b6aa22de270bbcb06684f80994d46
|
4
|
+
data.tar.gz: b345349594c6408775596e9189ca494671168f9b2acfecaeb9352aaa52d1b4b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d012764dfd32b2002ce51f6c94b9d8cc83836e947211bb7271166c674f19ba8f61f6683fcab6a8d30cd9668103d2abc4a73477105a35004a1af662aa13612b9
|
7
|
+
data.tar.gz: a094fff01bebad3fee84a8391918105f5f5f0c0b0707d8b935ef05b378b27f667751b601addfe77657b14ac48c428230d9cda4e76a34ad0e206b4d961d7812b2
|
data/lib/alterity.rb
CHANGED
@@ -12,8 +12,8 @@ class Alterity
|
|
12
12
|
when /^alter\s+table\s+(?<table>.+?)\s+(?<updates>.+)/i
|
13
13
|
table = $~[:table]
|
14
14
|
updates = $~[:updates]
|
15
|
-
if updates.split(",").all? { |s| s =~ /^\s*drop\s+foreign\s+key
|
16
|
-
updates.split(",").all? { |s| s =~ /^\s*add\s+constraint
|
15
|
+
if updates.split(",").all? { |s| s =~ /^\s*drop\s+foreign\s+key/i } ||
|
16
|
+
updates.split(",").all? { |s| s =~ /^\s*add\s+constraint/i }
|
17
17
|
block.call
|
18
18
|
elsif updates =~ /drop\s+foreign\s+key/i || updates =~ /add\s+constraint/i
|
19
19
|
# ADD CONSTRAINT / DROP FOREIGN KEY have to go to the original table,
|
data/lib/alterity/version.rb
CHANGED
data/spec/alterity_spec.rb
CHANGED
@@ -10,7 +10,7 @@ RSpec.describe Alterity do
|
|
10
10
|
["CREATE UNIQUE INDEX `idx_users_on_col` ON `users` (col)", "`users`", "ADD UNIQUE INDEX `idx_users_on_col` (col)"],
|
11
11
|
["DROP INDEX `idx_users_on_col` ON `users`", "`users`", "DROP INDEX `idx_users_on_col`"],
|
12
12
|
["alter table users drop col", "users", "drop col"],
|
13
|
-
[" ALTER TABLE\n users\n DROP col", "users", "DROP col"]
|
13
|
+
[" ALTER TABLE\n users\n DROP col", "users", "DROP col"],
|
14
14
|
].each do |(query, expected_table, expected_updates)|
|
15
15
|
puts query.inspect
|
16
16
|
expected_block = proc {}
|
@@ -32,7 +32,8 @@ RSpec.describe Alterity do
|
|
32
32
|
"SHOW FULL FIELDS FROM `users`",
|
33
33
|
"ALTER TABLE `installment_events` DROP FOREIGN KEY _fk_rails_0123456789",
|
34
34
|
"ALTER TABLE `installment_events` DROP FOREIGN KEY _fk_rails_0123456789, DROP FOREIGN KEY _fk_rails_9876543210",
|
35
|
-
"ALTER TABLE `installment_events` ADD CONSTRAINT `fk_rails_0cb5590091` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)"
|
35
|
+
"ALTER TABLE `installment_events` ADD CONSTRAINT `fk_rails_0cb5590091` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)",
|
36
|
+
"ALTER TABLE `installment_events` ADD CONSTRAINT `fk_rails_0cb5590091` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE",
|
36
37
|
].each do |query|
|
37
38
|
expected_block = proc {}
|
38
39
|
expect(expected_block).to receive(:call)
|