schema_plus_foreign_keys 1.0.0 → 1.1.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/.github/workflows/prs.yml +39 -0
- data/README.md +19 -10
- data/gemfiles/activerecord-6.1/Gemfile.base +4 -0
- data/gemfiles/activerecord-6.1/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-6.1/Gemfile.postgresql +10 -0
- data/gemfiles/activerecord-6.1/Gemfile.sqlite3 +10 -0
- data/gemfiles/activerecord-7.0/Gemfile.base +4 -0
- data/gemfiles/activerecord-7.0/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-7.0/Gemfile.postgresql +10 -0
- data/gemfiles/activerecord-7.0/Gemfile.sqlite3 +10 -0
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract/schema_creation.rb +12 -1
- data/lib/schema_plus/foreign_keys/middleware/dumper.rb +1 -1
- data/lib/schema_plus/foreign_keys/version.rb +1 -1
- data/lib/schema_plus/foreign_keys.rb +0 -1
- data/schema_dev.yml +3 -0
- data/schema_plus_foreign_keys.gemspec +3 -4
- data/spec/migration_spec.rb +1 -1
- data/spec/schema_dumper_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -4
- metadata +16 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d52c8d5e1603fd0f8ae8983aecaa1d2eee5fd4e245c640e6b6ee35e8667aac2
|
|
4
|
+
data.tar.gz: '0408a88c7312564391febf818176dc75aeb95ad40c9912745acb5fa6d94bb6ec'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa36101d0cd36e655727076beef61f11ef2ad47f6f47535ae38406bbfbba27c48008c2f7d3f604fb64a30d0f09bf2e4b7d32a40c2528c3852093adacae97f36a
|
|
7
|
+
data.tar.gz: d9e6164c36aef102bdf97d6a5a95d2be3b8395b5cdbcbf8dfdaba7bf04ba66e8bdf07a6f6903be31452106ed15b5334ebe20893ceb9279331df48936864259b7
|
data/.github/workflows/prs.yml
CHANGED
|
@@ -22,9 +22,12 @@ jobs:
|
|
|
22
22
|
- '2.5'
|
|
23
23
|
- '2.7'
|
|
24
24
|
- '3.0'
|
|
25
|
+
- '3.1'
|
|
25
26
|
activerecord:
|
|
26
27
|
- '5.2'
|
|
27
28
|
- '6.0'
|
|
29
|
+
- '6.1'
|
|
30
|
+
- '7.0'
|
|
28
31
|
db:
|
|
29
32
|
- mysql2
|
|
30
33
|
- sqlite3
|
|
@@ -34,6 +37,10 @@ jobs:
|
|
|
34
37
|
exclude:
|
|
35
38
|
- ruby: '3.0'
|
|
36
39
|
activerecord: '5.2'
|
|
40
|
+
- ruby: '3.1'
|
|
41
|
+
activerecord: '5.2'
|
|
42
|
+
- ruby: '2.5'
|
|
43
|
+
activerecord: '7.0'
|
|
37
44
|
- db: skip
|
|
38
45
|
dbversion: skip
|
|
39
46
|
include:
|
|
@@ -45,6 +52,10 @@ jobs:
|
|
|
45
52
|
activerecord: '6.0'
|
|
46
53
|
db: postgresql
|
|
47
54
|
dbversion: '9.6'
|
|
55
|
+
- ruby: '2.5'
|
|
56
|
+
activerecord: '6.1'
|
|
57
|
+
db: postgresql
|
|
58
|
+
dbversion: '9.6'
|
|
48
59
|
- ruby: '2.7'
|
|
49
60
|
activerecord: '5.2'
|
|
50
61
|
db: postgresql
|
|
@@ -53,10 +64,38 @@ jobs:
|
|
|
53
64
|
activerecord: '6.0'
|
|
54
65
|
db: postgresql
|
|
55
66
|
dbversion: '9.6'
|
|
67
|
+
- ruby: '2.7'
|
|
68
|
+
activerecord: '6.1'
|
|
69
|
+
db: postgresql
|
|
70
|
+
dbversion: '9.6'
|
|
71
|
+
- ruby: '2.7'
|
|
72
|
+
activerecord: '7.0'
|
|
73
|
+
db: postgresql
|
|
74
|
+
dbversion: '9.6'
|
|
75
|
+
- ruby: '3.0'
|
|
76
|
+
activerecord: '6.0'
|
|
77
|
+
db: postgresql
|
|
78
|
+
dbversion: '9.6'
|
|
79
|
+
- ruby: '3.0'
|
|
80
|
+
activerecord: '6.1'
|
|
81
|
+
db: postgresql
|
|
82
|
+
dbversion: '9.6'
|
|
56
83
|
- ruby: '3.0'
|
|
84
|
+
activerecord: '7.0'
|
|
85
|
+
db: postgresql
|
|
86
|
+
dbversion: '9.6'
|
|
87
|
+
- ruby: '3.1'
|
|
57
88
|
activerecord: '6.0'
|
|
58
89
|
db: postgresql
|
|
59
90
|
dbversion: '9.6'
|
|
91
|
+
- ruby: '3.1'
|
|
92
|
+
activerecord: '6.1'
|
|
93
|
+
db: postgresql
|
|
94
|
+
dbversion: '9.6'
|
|
95
|
+
- ruby: '3.1'
|
|
96
|
+
activerecord: '7.0'
|
|
97
|
+
db: postgresql
|
|
98
|
+
dbversion: '9.6'
|
|
60
99
|
env:
|
|
61
100
|
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
|
|
62
101
|
MYSQL_DB_HOST: 127.0.0.1
|
data/README.md
CHANGED
|
@@ -154,24 +154,33 @@ SchemaPlus::ForeignKeys is tested on:
|
|
|
154
154
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
|
155
155
|
* ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
156
156
|
* ruby **2.5** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
157
|
+
* ruby **2.5** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
157
158
|
* ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
158
159
|
* ruby **2.7** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
160
|
+
* ruby **2.7** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
161
|
+
* ruby **2.7** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
159
162
|
* ruby **3.0** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
163
|
+
* ruby **3.0** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
164
|
+
* ruby **3.0** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
165
|
+
* ruby **3.1** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
166
|
+
* ruby **3.1** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
167
|
+
* ruby **3.1** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
|
160
168
|
|
|
161
169
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
|
162
170
|
|
|
163
171
|
## History
|
|
164
172
|
|
|
165
|
-
* 1.
|
|
166
|
-
* 0.
|
|
167
|
-
* 0.1.
|
|
168
|
-
* 0.1.
|
|
169
|
-
* 0.1.
|
|
170
|
-
* 0.1.
|
|
171
|
-
* 0.1.
|
|
172
|
-
* 0.1.
|
|
173
|
-
* 0.1.
|
|
174
|
-
* 0.1.
|
|
173
|
+
* **1.1.0** - Add AR 6.1 and 7.0. Add Ruby 3.1, and drop schema_plus_compatibility dependency
|
|
174
|
+
* **1.0.0** - Drop Ruby < 2.5 and Rails < 5.2, adding Rails 6.0, and remove many deprecations
|
|
175
|
+
* **0.1.8** - Compatibility with ActiveRecord 5.1 and ActiveRecord 5.2.
|
|
176
|
+
* **0.1.7** - Compatibility with ActiveRecord 5.0.
|
|
177
|
+
* **0.1.6** - Missing require
|
|
178
|
+
* **0.1.5** - Explicit gem dependencies
|
|
179
|
+
* **0.1.4** - Upgrade schema_plus_core dependency
|
|
180
|
+
* **0.1.3** - Support aciverecord 4.2.6. Thanks to [@btsuhako](https://github.com/SchemaPlus/schema_plus_foreign_keys/issues?q=is%3Apr+is%3Aopen+author%3Abtsuhako) and [@dholdren](https://github.com/SchemaPlus/schema_plus_foreign_keys/issues?q=is%3Apr+is%3Aopen+author%3Adholdren)
|
|
181
|
+
* **0.1.2** - Handle very long names
|
|
182
|
+
* **0.1.1** - Cleanup; use (new) core Migration::RenameTable stack rather than monkey patching.
|
|
183
|
+
* **0.1.0** - Initial release, brought over from schema_plus 1.x via 2.0.0.pre*
|
|
175
184
|
|
|
176
185
|
## Development & Testing
|
|
177
186
|
|
data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract/schema_creation.rb
CHANGED
|
@@ -4,7 +4,18 @@ module SchemaPlus
|
|
|
4
4
|
module Core
|
|
5
5
|
module ActiveRecord
|
|
6
6
|
module ConnectionAdapters
|
|
7
|
-
|
|
7
|
+
if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
|
|
8
|
+
module AbstractAdapter
|
|
9
|
+
module SchemaCreation
|
|
10
|
+
|
|
11
|
+
def visit_ForeignKeyDefinition(o)
|
|
12
|
+
# schema_plus_foreign_keys already implements a superior
|
|
13
|
+
# conversion of ForeignKeyDefinitions to SQL
|
|
14
|
+
o.to_sql
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
else
|
|
8
19
|
module SchemaCreation
|
|
9
20
|
|
|
10
21
|
def visit_ForeignKeyDefinition(o)
|
|
@@ -16,7 +16,7 @@ module SchemaPlus::ForeignKeys
|
|
|
16
16
|
@inline_fks = Hash.new{ |h, k| h[k] = [] }
|
|
17
17
|
@backref_fks = Hash.new{ |h, k| h[k] = [] }
|
|
18
18
|
|
|
19
|
-
env.connection.
|
|
19
|
+
env.connection.tables.each do |table|
|
|
20
20
|
if (fks = env.connection.foreign_keys(table)).any?
|
|
21
21
|
env.dump.data.has_fks = true
|
|
22
22
|
@inline_fks[table] = fks
|
data/schema_dev.yml
CHANGED
|
@@ -22,13 +22,12 @@ Gem::Specification.new do |gem|
|
|
|
22
22
|
|
|
23
23
|
gem.required_ruby_version = ">= 2.5.0"
|
|
24
24
|
|
|
25
|
-
gem.add_dependency "activerecord", ">= 5.2", "<
|
|
26
|
-
gem.add_dependency "schema_plus_core", "~> 3.
|
|
27
|
-
gem.add_dependency "schema_plus_compatibility", "~> 1.0.0"
|
|
25
|
+
gem.add_dependency "activerecord", ">= 5.2", "< 7.1"
|
|
26
|
+
gem.add_dependency "schema_plus_core", "~> 3.1.0"
|
|
28
27
|
gem.add_dependency "valuable"
|
|
29
28
|
|
|
30
29
|
gem.add_development_dependency "bundler"
|
|
31
30
|
gem.add_development_dependency "rake", "~> 13.0"
|
|
32
31
|
gem.add_development_dependency "rspec", "~> 3.0"
|
|
33
|
-
gem.add_development_dependency "schema_dev", "~> 4.
|
|
32
|
+
gem.add_development_dependency "schema_dev", "~> 4.2.0"
|
|
34
33
|
end
|
data/spec/migration_spec.rb
CHANGED
|
@@ -333,7 +333,7 @@ describe ActiveRecord::Migration do
|
|
|
333
333
|
it "should remove a foreign key constraint"+suffix, :sqlite3 => :skip do
|
|
334
334
|
Comment.reset_column_information
|
|
335
335
|
expect(Comment).to reference(:users, :id).on(:user_id)
|
|
336
|
-
migration = Class.new ::ActiveRecord::Migration
|
|
336
|
+
migration = Class.new ::ActiveRecord::Migration::Current do
|
|
337
337
|
define_method(:change) {
|
|
338
338
|
change_table("comments", :bulk => bulk) do |t|
|
|
339
339
|
t.references :user, foreign_key: true
|
data/spec/schema_dumper_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe "Schema dump" do
|
|
|
7
7
|
before(:each) do
|
|
8
8
|
ActiveRecord::Migration.suppress_messages do
|
|
9
9
|
ActiveRecord::Schema.define do
|
|
10
|
-
connection.
|
|
10
|
+
connection.tables.each do |table| drop_table table, force: :cascade end
|
|
11
11
|
|
|
12
12
|
create_table :users, force: true do |t|
|
|
13
13
|
t.string :login
|
|
@@ -144,7 +144,7 @@ describe "Schema dump" do
|
|
|
144
144
|
|
|
145
145
|
ActiveRecord::Migration.suppress_messages do
|
|
146
146
|
ActiveRecord::Schema.define do
|
|
147
|
-
connection.
|
|
147
|
+
connection.tables.each do |table| drop_table table, force: :cascade end
|
|
148
148
|
|
|
149
149
|
create_table :grade_systems, force: true do |t|
|
|
150
150
|
t.string :name
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'simplecov'
|
|
4
|
-
|
|
5
|
-
SimpleCov.start
|
|
4
|
+
SimpleCov.start unless SimpleCov.running
|
|
6
5
|
|
|
7
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
8
7
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
@@ -24,7 +23,7 @@ RSpec.configure do |config|
|
|
|
24
23
|
begin
|
|
25
24
|
example.run
|
|
26
25
|
ensure
|
|
27
|
-
ActiveRecord::Base.connection.
|
|
26
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
|
28
27
|
ActiveRecord::Migration.drop_table table, force: :cascade
|
|
29
28
|
end
|
|
30
29
|
end
|
|
@@ -50,7 +49,7 @@ def define_schema(config={}, &block)
|
|
|
50
49
|
with_fk_config(config) do
|
|
51
50
|
ActiveRecord::Migration.suppress_messages do
|
|
52
51
|
ActiveRecord::Schema.define do
|
|
53
|
-
connection.
|
|
52
|
+
connection.tables.each do |table|
|
|
54
53
|
drop_table table, force: :cascade
|
|
55
54
|
end
|
|
56
55
|
instance_eval &block
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: schema_plus_foreign_keys
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ronen barzel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-06-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: '5.2'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '7.1'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,35 +29,21 @@ dependencies:
|
|
|
29
29
|
version: '5.2'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '7.1'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: schema_plus_core
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 3.
|
|
39
|
+
version: 3.1.0
|
|
40
40
|
type: :runtime
|
|
41
41
|
prerelease: false
|
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 3.
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: schema_plus_compatibility
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.0.0
|
|
54
|
-
type: :runtime
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: 1.0.0
|
|
46
|
+
version: 3.1.0
|
|
61
47
|
- !ruby/object:Gem::Dependency
|
|
62
48
|
name: valuable
|
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,14 +106,14 @@ dependencies:
|
|
|
120
106
|
requirements:
|
|
121
107
|
- - "~>"
|
|
122
108
|
- !ruby/object:Gem::Version
|
|
123
|
-
version:
|
|
109
|
+
version: 4.2.0
|
|
124
110
|
type: :development
|
|
125
111
|
prerelease: false
|
|
126
112
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
113
|
requirements:
|
|
128
114
|
- - "~>"
|
|
129
115
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
116
|
+
version: 4.2.0
|
|
131
117
|
description: 'Extended support for foreign key constraints in ActiveRecord, including:
|
|
132
118
|
definition as column attribute; deferrable; and SQLite3 support; cleaner dumps;
|
|
133
119
|
and more!'
|
|
@@ -153,6 +139,14 @@ files:
|
|
|
153
139
|
- gemfiles/activerecord-6.0/Gemfile.mysql2
|
|
154
140
|
- gemfiles/activerecord-6.0/Gemfile.postgresql
|
|
155
141
|
- gemfiles/activerecord-6.0/Gemfile.sqlite3
|
|
142
|
+
- gemfiles/activerecord-6.1/Gemfile.base
|
|
143
|
+
- gemfiles/activerecord-6.1/Gemfile.mysql2
|
|
144
|
+
- gemfiles/activerecord-6.1/Gemfile.postgresql
|
|
145
|
+
- gemfiles/activerecord-6.1/Gemfile.sqlite3
|
|
146
|
+
- gemfiles/activerecord-7.0/Gemfile.base
|
|
147
|
+
- gemfiles/activerecord-7.0/Gemfile.mysql2
|
|
148
|
+
- gemfiles/activerecord-7.0/Gemfile.postgresql
|
|
149
|
+
- gemfiles/activerecord-7.0/Gemfile.sqlite3
|
|
156
150
|
- lib/schema_plus/foreign_keys.rb
|
|
157
151
|
- lib/schema_plus/foreign_keys/active_record/base.rb
|
|
158
152
|
- lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract/schema_creation.rb
|