schema_auto_foreign_keys 1.0.0 → 1.1.0
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 +9 -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_auto_foreign_keys/version.rb +1 -1
- data/schema_auto_foreign_keys.gemspec +4 -3
- data/schema_dev.yml +3 -0
- data/spec/migration_spec.rb +1 -1
- data/spec/schema_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +37 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f81706ea91cc1d110fb64e9ef09aeee7cf124094121a18a54f5198f4695054
|
4
|
+
data.tar.gz: 7f808933b2bf19df48f758aa568dfa7829ead1e6c8cf24135212bfe2833e0739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729c74ff414f06b54faf2ddf851c29f636f7f8b5e3576aa117b7806cc9e715b4ebb4c94ba02b2a5bf667a15c947295f68ae84d2010fa7b47894ec4bbb3e0bf58
|
7
|
+
data.tar.gz: 59a77d7eaaa60c7a32e8e2281cd8674c69b24b4d19cee9350e0df2fc65c0a0f86e1d87257ac6e0ebe679850e577722eb2e97bdf6b1d5cee16d9e908b7da6a4b6
|
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
@@ -89,9 +89,17 @@ SchemaAutoForeignKeys is tested on:
|
|
89
89
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
90
90
|
* ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
91
91
|
* ruby **2.5** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
92
|
+
* ruby **2.5** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
92
93
|
* ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
93
94
|
* ruby **2.7** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
95
|
+
* ruby **2.7** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
96
|
+
* ruby **2.7** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
94
97
|
* ruby **3.0** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
98
|
+
* ruby **3.0** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
99
|
+
* ruby **3.0** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
100
|
+
* ruby **3.1** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
101
|
+
* ruby **3.1** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
102
|
+
* ruby **3.1** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
95
103
|
|
96
104
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
97
105
|
|
@@ -105,6 +113,7 @@ SQlite3 doesn't support renaming the auto-index whtn the table name changes.
|
|
105
113
|
|
106
114
|
## History
|
107
115
|
|
116
|
+
* 1.1.0 - Add AR 6.1 and 7.0, Add Ruby 3.1. remvoe schema_plus_compatiblity dependency
|
108
117
|
* 1.0.0 - Drop Ruby < 2.5 and Rails < 5.2, add Rails 6.0, and remove many deprecations
|
109
118
|
* 0.1.3 - AR5 (Rails 5) Support
|
110
119
|
* 0.1.2 - Missing require
|
@@ -20,11 +20,12 @@ Gem::Specification.new do |gem|
|
|
20
20
|
|
21
21
|
gem.required_ruby_version = ">= 2.5.0"
|
22
22
|
|
23
|
-
gem.add_dependency "
|
24
|
-
gem.add_dependency "
|
23
|
+
gem.add_dependency "activerecord", ">= 5.2", "< 7.1"
|
24
|
+
gem.add_dependency "schema_plus_foreign_keys", "~> 1.1.0"
|
25
|
+
gem.add_dependency "schema_plus_indexes", "~> 1.0.1"
|
25
26
|
|
26
27
|
gem.add_development_dependency "bundler"
|
27
28
|
gem.add_development_dependency "rake", "~> 13.0"
|
28
29
|
gem.add_development_dependency "rspec", "~> 3.0"
|
29
|
-
gem.add_development_dependency "schema_dev", "~> 4.
|
30
|
+
gem.add_development_dependency "schema_dev", "~> 4.2.0"
|
30
31
|
end
|
data/schema_dev.yml
CHANGED
data/spec/migration_spec.rb
CHANGED
@@ -220,7 +220,7 @@ describe ActiveRecord::Migration do
|
|
220
220
|
end
|
221
221
|
expect(Comment).to reference(:users, :id).on(:user_id)
|
222
222
|
expect(Comment).to have_index.on(:user_id)
|
223
|
-
migration = Class.new ::ActiveRecord::Migration
|
223
|
+
migration = Class.new ::ActiveRecord::Migration::Current do
|
224
224
|
define_method(:change) {
|
225
225
|
change_table("comments", bulk: bulk) do |t|
|
226
226
|
t.bigint :user_id
|
data/spec/schema_spec.rb
CHANGED
@@ -30,11 +30,11 @@ describe ActiveRecord::Schema do
|
|
30
30
|
|
31
31
|
it "creates only explicity added indexes" do
|
32
32
|
expected = SchemaDev::Rspec::Helpers.mysql? ? 2 : 1
|
33
|
-
expect(connection.
|
33
|
+
expect(connection.tables.collect { |table| connection.indexes(table) }.flatten.size).to eq(expected)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should create only explicity added foriegn keys" do
|
37
|
-
expect(connection.
|
37
|
+
expect(connection.tables.collect { |table| connection.foreign_keys(table) }.flatten.size).to eq(2)
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
SimpleCov.start
|
2
|
+
SimpleCov.start unless SimpleCov.running
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -41,7 +41,7 @@ end
|
|
41
41
|
|
42
42
|
def define_schema(&block)
|
43
43
|
ActiveRecord::Schema.define do
|
44
|
-
connection.
|
44
|
+
connection.tables.each do |table|
|
45
45
|
drop_table table, force: :cascade
|
46
46
|
end
|
47
47
|
instance_eval &block
|
metadata
CHANGED
@@ -1,43 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_auto_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
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.1'
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: schema_plus_foreign_keys
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
16
36
|
requirements:
|
17
37
|
- - "~>"
|
18
38
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
39
|
+
version: 1.1.0
|
20
40
|
type: :runtime
|
21
41
|
prerelease: false
|
22
42
|
version_requirements: !ruby/object:Gem::Requirement
|
23
43
|
requirements:
|
24
44
|
- - "~>"
|
25
45
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
46
|
+
version: 1.1.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: schema_plus_indexes
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
30
50
|
requirements:
|
31
51
|
- - "~>"
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.
|
53
|
+
version: 1.0.1
|
34
54
|
type: :runtime
|
35
55
|
prerelease: false
|
36
56
|
version_requirements: !ruby/object:Gem::Requirement
|
37
57
|
requirements:
|
38
58
|
- - "~>"
|
39
59
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.
|
60
|
+
version: 1.0.1
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: bundler
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +106,14 @@ dependencies:
|
|
86
106
|
requirements:
|
87
107
|
- - "~>"
|
88
108
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
109
|
+
version: 4.2.0
|
90
110
|
type: :development
|
91
111
|
prerelease: false
|
92
112
|
version_requirements: !ruby/object:Gem::Requirement
|
93
113
|
requirements:
|
94
114
|
- - "~>"
|
95
115
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
116
|
+
version: 4.2.0
|
97
117
|
description: In an ActiveRecord migration, set the default to create a foreign key
|
98
118
|
and index for all columns that define relatoins.
|
99
119
|
email:
|
@@ -118,6 +138,14 @@ files:
|
|
118
138
|
- gemfiles/activerecord-6.0/Gemfile.mysql2
|
119
139
|
- gemfiles/activerecord-6.0/Gemfile.postgresql
|
120
140
|
- gemfiles/activerecord-6.0/Gemfile.sqlite3
|
141
|
+
- gemfiles/activerecord-6.1/Gemfile.base
|
142
|
+
- gemfiles/activerecord-6.1/Gemfile.mysql2
|
143
|
+
- gemfiles/activerecord-6.1/Gemfile.postgresql
|
144
|
+
- gemfiles/activerecord-6.1/Gemfile.sqlite3
|
145
|
+
- gemfiles/activerecord-7.0/Gemfile.base
|
146
|
+
- gemfiles/activerecord-7.0/Gemfile.mysql2
|
147
|
+
- gemfiles/activerecord-7.0/Gemfile.postgresql
|
148
|
+
- gemfiles/activerecord-7.0/Gemfile.sqlite3
|
121
149
|
- lib/schema_auto_foreign_keys.rb
|
122
150
|
- lib/schema_auto_foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb
|
123
151
|
- lib/schema_auto_foreign_keys/middleware/migration.rb
|
@@ -150,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
178
|
- !ruby/object:Gem::Version
|
151
179
|
version: '0'
|
152
180
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
181
|
+
rubygems_version: 3.1.6
|
154
182
|
signing_key:
|
155
183
|
specification_version: 4
|
156
184
|
summary: Automatically define foreign key constraints in ActiveRecord
|