schema_plus_foreign_keys 1.0.0 → 1.0.1.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/prs.yml +39 -0
- data/README.md +8 -0
- 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 +19 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 908d8a51b4209f2d5cb5a076c5a1b11d79208a17fcffc896d3c995e5b14309cd
|
4
|
+
data.tar.gz: 5dccb00914ac44f9c0fdbb34562f011ab7f0e5b8bdfd11c922a6af7b5a3c67aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e137a69ef309c52a153a8f4371894e1c5d902def148d59c944888420f7e87998102bf76747932fc8a0f479d0087256c9400b115fade8b8a528802209df7a3238
|
7
|
+
data.tar.gz: d57e9862252616ed588296571a9148f13673ac49f52bdd29d485d13f38d2a23ce0bb096351ff53adb31258c5815793cb3c324753ff3de5b8053579e973c7b4ed
|
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,9 +154,17 @@ 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
|
|
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.0.
|
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.beta.2"
|
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.1"
|
32
|
+
gem.add_development_dependency "schema_dev", "~> 4.2.beta.1"
|
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.0.
|
4
|
+
version: 1.0.1.beta.1
|
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-05-
|
11
|
+
date: 2022-05-11 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.0.
|
39
|
+
version: 3.1.0.beta.2
|
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.0.
|
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.beta.2
|
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.beta.1
|
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.beta.1
|
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
|
@@ -195,11 +189,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
189
|
version: 2.5.0
|
196
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
191
|
requirements:
|
198
|
-
- - "
|
192
|
+
- - ">"
|
199
193
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
194
|
+
version: 1.3.1
|
201
195
|
requirements: []
|
202
|
-
rubygems_version: 3.
|
196
|
+
rubygems_version: 3.3.7
|
203
197
|
signing_key:
|
204
198
|
specification_version: 4
|
205
199
|
summary: Extended support for foreign key constraints in ActiveRecord
|