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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6283968b3d028f736da1517832ee5ebf8410aa4281aea4a2fa7af9e868a7ef89
4
- data.tar.gz: c4e6ae366bea0f1065aa303824c0f64f7dc684f7566e600ede7ece16c4e58b60
3
+ metadata.gz: af06f20537df45280990abc9fd8c2235741b6aa22de270bbcb06684f80994d46
4
+ data.tar.gz: b345349594c6408775596e9189ca494671168f9b2acfecaeb9352aaa52d1b4b8
5
5
  SHA512:
6
- metadata.gz: 1bf501f5c7f2ce204f995341c7ee2bf73a0c3d8fc16ed9b32ea710ff4b77251e464891df9866a6847b7740ae9472f1c639cae7b7ac31bb82381616b84d5ea66b
7
- data.tar.gz: 58fb3f6708f0b610d4129c960f1765e5073d74e0170f46456d549cf3f65ecf8e34da7b139efee3afbb5575d0f0c01d5630170590d51ffba2b6de9ef8d52e4a1c
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\s+\w+\s*$/i } ||
16
- updates.split(",").all? { |s| s =~ /^\s*add\s+constraint\s+`?\w+`?\s+foreign\s+key\s+\(`?\w+`?\)\s+references\s+`?\w+`?\s+\(`?\w+`?\)\s*$/i }
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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Alterity
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alterity
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Maximin