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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4320accfc977e0693af01ea8da225767890fe058a20e2fb38a5b3e17d96e5f8a
4
- data.tar.gz: 7bb518bae024a887cefc969ec98b0c6b8c79f6818386e04362fe294622c7596c
3
+ metadata.gz: 2d52c8d5e1603fd0f8ae8983aecaa1d2eee5fd4e245c640e6b6ee35e8667aac2
4
+ data.tar.gz: '0408a88c7312564391febf818176dc75aeb95ad40c9912745acb5fa6d94bb6ec'
5
5
  SHA512:
6
- metadata.gz: 8378363061d53b5f479c12e333489efb6206f47aaf259e50852346f437cd90662dc3efbbb2c2337ef562a29b5f4d92cdd8e5a3f2e7a8c015f70fdc1c5f2e6f3d
7
- data.tar.gz: 4a67d8e35b227029cf1af8834d0e387afddded929504a78ccae97a65a0563a8e2bab34f179315a57e8d1990fc1d8544f1cf36cfb2574ec6740a2d92890d74420
6
+ metadata.gz: aa36101d0cd36e655727076beef61f11ef2ad47f6f47535ae38406bbfbba27c48008c2f7d3f604fb64a30d0f09bf2e4b7d32a40c2528c3852093adacae97f36a
7
+ data.tar.gz: d9e6164c36aef102bdf97d6a5a95d2be3b8395b5cdbcbf8dfdaba7bf04ba66e8bdf07a6f6903be31452106ed15b5334ebe20893ceb9279331df48936864259b7
@@ -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.0.0 - Drop Ruby < 2.5 and Rails < 5.2, adding Rails 6.0, and remove many deprecations
166
- * 0.1.8 - Compatibility with ActiveRecord 5.1 and ActiveRecord 5.2.
167
- * 0.1.7 - Compatibility with ActiveRecord 5.0.
168
- * 0.1.6 - Missing require
169
- * 0.1.5 - Explicit gem dependencies
170
- * 0.1.4 - Upgrade schema_plus_core dependency
171
- * 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)
172
- * 0.1.2 - Handle very long names
173
- * 0.1.1 - Cleanup; use (new) core Migration::RenameTable stack rather than monkey patching.
174
- * 0.1.0 - Initial release, brought over from schema_plus 1.x via 2.0.0.pre*
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
 
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.1", "< 6.2"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 7.0", "< 7.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -4,7 +4,18 @@ module SchemaPlus
4
4
  module Core
5
5
  module ActiveRecord
6
6
  module ConnectionAdapters
7
- module AbstractAdapter
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.tables_only.each do |table|
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SchemaPlus
4
4
  module ForeignKeys
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'schema_plus/core'
4
- require 'schema_plus_compatibility'
5
4
  require 'valuable'
6
5
 
7
6
  require_relative 'foreign_keys/version'
data/schema_dev.yml CHANGED
@@ -2,9 +2,12 @@ ruby:
2
2
  - 2.5
3
3
  - 2.7
4
4
  - 3.0
5
+ - 3.1
5
6
  activerecord:
6
7
  - 5.2
7
8
  - 6.0
9
+ - 6.1
10
+ - 7.0
8
11
  db:
9
12
  - mysql2
10
13
  - sqlite3
@@ -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", "< 6.1"
26
- gem.add_dependency "schema_plus_core", "~> 3.0.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"
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.0"
34
33
  end
@@ -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.latest_version do
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
@@ -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.tables_only.each do |table| drop_table table, force: :cascade end
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.tables_only.each do |table| drop_table table, force: :cascade end
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.tables_only.each do |table|
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.tables_only.each do |table|
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.0
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-05-06 00:00:00.000000000 Z
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: '6.1'
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: '6.1'
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.0
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.0.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
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: '4.1'
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: '4.1'
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