schema_plus_foreign_keys 0.1.7 → 1.0.1.beta.1

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.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/prs.yml +173 -0
  3. data/.gitignore +1 -0
  4. data/.simplecov +20 -0
  5. data/Gemfile +4 -1
  6. data/README.md +56 -35
  7. data/Rakefile +3 -1
  8. data/gemfiles/Gemfile.base +1 -1
  9. data/gemfiles/activerecord-5.2/Gemfile.base +4 -0
  10. data/gemfiles/activerecord-5.2/Gemfile.mysql2 +10 -0
  11. data/gemfiles/activerecord-5.2/Gemfile.postgresql +10 -0
  12. data/gemfiles/{activerecord-4.2.0 → activerecord-5.2}/Gemfile.sqlite3 +3 -3
  13. data/gemfiles/activerecord-6.0/Gemfile.base +4 -0
  14. data/gemfiles/activerecord-6.0/Gemfile.mysql2 +10 -0
  15. data/gemfiles/activerecord-6.0/Gemfile.postgresql +10 -0
  16. data/gemfiles/{activerecord-4.2.6 → activerecord-6.0}/Gemfile.sqlite3 +3 -3
  17. data/gemfiles/activerecord-6.1/Gemfile.base +4 -0
  18. data/gemfiles/activerecord-6.1/Gemfile.mysql2 +10 -0
  19. data/gemfiles/activerecord-6.1/Gemfile.postgresql +10 -0
  20. data/gemfiles/{activerecord-5.0 → activerecord-6.1}/Gemfile.sqlite3 +3 -3
  21. data/gemfiles/activerecord-7.0/Gemfile.base +4 -0
  22. data/gemfiles/activerecord-7.0/Gemfile.mysql2 +10 -0
  23. data/gemfiles/activerecord-7.0/Gemfile.postgresql +10 -0
  24. data/gemfiles/{activerecord-4.2.1 → activerecord-7.0}/Gemfile.sqlite3 +3 -3
  25. data/lib/schema_plus/foreign_keys/active_record/base.rb +2 -0
  26. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract/schema_creation.rb +14 -12
  27. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb +7 -47
  28. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/foreign_key_definition.rb +4 -35
  29. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/mysql2_adapter.rb +15 -16
  30. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/postgresql_adapter.rb +8 -6
  31. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb +8 -6
  32. data/lib/schema_plus/foreign_keys/active_record/connection_adapters/table_definition.rb +10 -49
  33. data/lib/schema_plus/foreign_keys/active_record/migration/command_recorder.rb +4 -2
  34. data/lib/schema_plus/foreign_keys/middleware/dumper.rb +5 -3
  35. data/lib/schema_plus/foreign_keys/middleware/migration.rb +13 -5
  36. data/lib/schema_plus/foreign_keys/middleware/model.rb +2 -0
  37. data/lib/schema_plus/foreign_keys/middleware/mysql.rb +3 -1
  38. data/lib/schema_plus/foreign_keys/middleware/sql.rb +2 -16
  39. data/lib/schema_plus/foreign_keys/version.rb +3 -1
  40. data/lib/schema_plus/foreign_keys.rb +2 -2
  41. data/lib/schema_plus_foreign_keys.rb +2 -0
  42. data/schema_dev.yml +8 -5
  43. data/schema_plus_foreign_keys.gemspec +9 -9
  44. data/spec/deprecation_spec.rb +14 -113
  45. data/spec/foreign_key_definition_spec.rb +5 -3
  46. data/spec/foreign_key_spec.rb +26 -24
  47. data/spec/migration_spec.rb +73 -91
  48. data/spec/named_schemas_spec.rb +16 -14
  49. data/spec/schema_dumper_spec.rb +36 -35
  50. data/spec/spec_helper.rb +5 -4
  51. data/spec/support/reference.rb +3 -2
  52. metadata +41 -97
  53. data/.travis.yml +0 -27
  54. data/gemfiles/activerecord-4.2.0/Gemfile.base +0 -3
  55. data/gemfiles/activerecord-4.2.0/Gemfile.mysql2 +0 -10
  56. data/gemfiles/activerecord-4.2.0/Gemfile.postgresql +0 -10
  57. data/gemfiles/activerecord-4.2.1/Gemfile.base +0 -3
  58. data/gemfiles/activerecord-4.2.1/Gemfile.mysql2 +0 -10
  59. data/gemfiles/activerecord-4.2.1/Gemfile.postgresql +0 -10
  60. data/gemfiles/activerecord-4.2.6/Gemfile.base +0 -3
  61. data/gemfiles/activerecord-4.2.6/Gemfile.mysql2 +0 -10
  62. data/gemfiles/activerecord-4.2.6/Gemfile.postgresql +0 -10
  63. data/gemfiles/activerecord-5.0/Gemfile.base +0 -3
  64. data/gemfiles/activerecord-5.0/Gemfile.mysql2 +0 -10
  65. data/gemfiles/activerecord-5.0/Gemfile.postgresql +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3c82c1e41e5b9f6ca1cfb1f5d4df97db636f573f
4
- data.tar.gz: ae9f1d6d16f4e77f36dd5b8246873b50da4d8ba8
2
+ SHA256:
3
+ metadata.gz: 908d8a51b4209f2d5cb5a076c5a1b11d79208a17fcffc896d3c995e5b14309cd
4
+ data.tar.gz: 5dccb00914ac44f9c0fdbb34562f011ab7f0e5b8bdfd11c922a6af7b5a3c67aa
5
5
  SHA512:
6
- metadata.gz: c88017019c8f44d10b3b833e8f19e1612f0311f5a07c0c05af87046c87e238081cfc0811af6e813a68365d523ec51c4343e7e6ebe30024cd3577c9f0aaef6e68
7
- data.tar.gz: 12e0728c42a03ba247ddd28e3885e1cfc1f3948ecbb46bb10baafb389db218952358d0762c4e79ef5ddff280457fd63ba289cd1fb81258ea8c67190a42a90a0f
6
+ metadata.gz: e137a69ef309c52a153a8f4371894e1c5d902def148d59c944888420f7e87998102bf76747932fc8a0f479d0087256c9400b115fade8b8a528802209df7a3238
7
+ data.tar.gz: d57e9862252616ed588296571a9148f13673ac49f52bdd29d485d13f38d2a23ce0bb096351ff53adb31258c5815793cb3c324753ff3de5b8053579e973c7b4ed
@@ -0,0 +1,173 @@
1
+ # This file was auto-generated by the schema_dev tool, based on the data in
2
+ # ./schema_dev.yml
3
+ # Please do not edit this file; any changes will be overwritten next time
4
+ # schema_dev gets run.
5
+ ---
6
+ name: CI PR Builds
7
+ 'on':
8
+ push:
9
+ branches:
10
+ - master
11
+ pull_request:
12
+ concurrency:
13
+ group: ci-${{ github.ref }}
14
+ cancel-in-progress: true
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby:
22
+ - '2.5'
23
+ - '2.7'
24
+ - '3.0'
25
+ - '3.1'
26
+ activerecord:
27
+ - '5.2'
28
+ - '6.0'
29
+ - '6.1'
30
+ - '7.0'
31
+ db:
32
+ - mysql2
33
+ - sqlite3
34
+ - skip
35
+ dbversion:
36
+ - skip
37
+ exclude:
38
+ - ruby: '3.0'
39
+ activerecord: '5.2'
40
+ - ruby: '3.1'
41
+ activerecord: '5.2'
42
+ - ruby: '2.5'
43
+ activerecord: '7.0'
44
+ - db: skip
45
+ dbversion: skip
46
+ include:
47
+ - ruby: '2.5'
48
+ activerecord: '5.2'
49
+ db: postgresql
50
+ dbversion: '9.6'
51
+ - ruby: '2.5'
52
+ activerecord: '6.0'
53
+ db: postgresql
54
+ dbversion: '9.6'
55
+ - ruby: '2.5'
56
+ activerecord: '6.1'
57
+ db: postgresql
58
+ dbversion: '9.6'
59
+ - ruby: '2.7'
60
+ activerecord: '5.2'
61
+ db: postgresql
62
+ dbversion: '9.6'
63
+ - ruby: '2.7'
64
+ activerecord: '6.0'
65
+ db: postgresql
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'
83
+ - ruby: '3.0'
84
+ activerecord: '7.0'
85
+ db: postgresql
86
+ dbversion: '9.6'
87
+ - ruby: '3.1'
88
+ activerecord: '6.0'
89
+ db: postgresql
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'
99
+ env:
100
+ BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
101
+ MYSQL_DB_HOST: 127.0.0.1
102
+ MYSQL_DB_USER: root
103
+ MYSQL_DB_PASS: database
104
+ POSTGRESQL_DB_HOST: 127.0.0.1
105
+ POSTGRESQL_DB_USER: schema_plus_test
106
+ POSTGRESQL_DB_PASS: database
107
+ steps:
108
+ - uses: actions/checkout@v2
109
+ - name: Set up Ruby
110
+ uses: ruby/setup-ruby@v1
111
+ with:
112
+ ruby-version: "${{ matrix.ruby }}"
113
+ bundler-cache: true
114
+ - name: Run bundle update
115
+ run: bundle update
116
+ - name: Start Mysql
117
+ if: matrix.db == 'mysql2'
118
+ run: |
119
+ docker run --rm --detach \
120
+ -e MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASS \
121
+ -p 3306:3306 \
122
+ --health-cmd "mysqladmin ping --host=127.0.0.1 --password=$MYSQL_DB_PASS --silent" \
123
+ --health-interval 5s \
124
+ --health-timeout 5s \
125
+ --health-retries 5 \
126
+ --name database mysql:5.6
127
+ - name: Start Postgresql
128
+ if: matrix.db == 'postgresql'
129
+ run: |
130
+ docker run --rm --detach \
131
+ -e POSTGRES_USER=$POSTGRESQL_DB_USER \
132
+ -e POSTGRES_PASSWORD=$POSTGRESQL_DB_PASS \
133
+ -p 5432:5432 \
134
+ --health-cmd "pg_isready -q" \
135
+ --health-interval 5s \
136
+ --health-timeout 5s \
137
+ --health-retries 5 \
138
+ --name database postgres:${{ matrix.dbversion }}
139
+ - name: Wait for database to start
140
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
141
+ run: |
142
+ COUNT=0
143
+ ATTEMPTS=20
144
+ until [[ $COUNT -eq $ATTEMPTS ]]; do
145
+ [ "$(docker inspect -f {{.State.Health.Status}} database)" == "healthy" ] && break
146
+ echo $(( COUNT++ )) > /dev/null
147
+ sleep 2
148
+ done
149
+ - name: Create testing database
150
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
151
+ run: bundle exec rake create_ci_database
152
+ - name: Run tests
153
+ run: bundle exec rake spec
154
+ - name: Shutdown database
155
+ if: always() && (matrix.db == 'postgresql' || matrix.db == 'mysql2')
156
+ run: docker stop database
157
+ - name: Coveralls Parallel
158
+ if: "${{ !env.ACT }}"
159
+ uses: coverallsapp/github-action@master
160
+ with:
161
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
162
+ flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}-${{ matrix.db }}-${{ matrix.dbversion }}
163
+ parallel: true
164
+ finish:
165
+ needs: test
166
+ runs-on: ubuntu-latest
167
+ steps:
168
+ - name: Coveralls Finished
169
+ if: "${{ !env.ACT }}"
170
+ uses: coverallsapp/github-action@master
171
+ with:
172
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
173
+ parallel-finished: true
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  /tmp
3
3
  /pkg
4
4
  /Gemfile.local
5
+ /.idea
5
6
 
6
7
  *.lock
7
8
  *.log
data/.simplecov ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.configure do
4
+ enable_coverage :branch
5
+ add_filter '/spec/'
6
+
7
+ add_group 'Binaries', '/bin/'
8
+ add_group 'Libraries', '/lib/'
9
+
10
+ if ENV['CI']
11
+ require 'simplecov-lcov'
12
+
13
+ SimpleCov::Formatter::LcovFormatter.config do |c|
14
+ c.report_with_single_file = true
15
+ c.single_report_path = 'coverage/lcov.info'
16
+ end
17
+
18
+ formatter SimpleCov::Formatter::LcovFormatter
19
+ end
20
+ end
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "http://rubygems.org"
2
4
 
3
5
  gemspec
4
6
 
5
- File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
7
+ gemfile_local = File.expand_path '../Gemfile.local', __FILE__
8
+ eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
data/README.md CHANGED
@@ -1,14 +1,17 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/schema_plus_foreign_keys.svg)](http://badge.fury.io/rb/schema_plus_foreign_keys)
2
- [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_plus_foreign_keys.svg)](http://travis-ci.org/SchemaPlus/schema_plus_foreign_keys)
3
- [![Coverage Status](https://img.shields.io/coveralls/SchemaPlus/schema_plus_foreign_keys.svg)](https://coveralls.io/r/SchemaPlus/schema_plus_foreign_keys)
2
+ [![Build Status](https://github.com/SchemaPlus/schema_plus_foreign_keys/actions/workflows/prs.yml/badge.svg)](https://github.com/SchemaPlus/schema_plus_foreign_keys/actions)
3
+ [![Coverage Status](https://coveralls.io/repos/github/SchemaPlus/schema_plus_foreign_keys/badge.svg)](https://coveralls.io/github/SchemaPlus/schema_plus_foreign_keys)
4
4
 
5
5
  # SchemaPlus::ForeignKeys
6
6
 
7
- SchemaPlus::ForeignKeys provides extended support in ActiveRecord. This includes extended support for declaraing foreign key constraints in migrations; support for deferrable constraints; support for SQLite3; cleaner schema dumps.
7
+ SchemaPlus::ForeignKeys provides extended support in ActiveRecord. This includes extended support for declaring
8
+ foreign key constraints in migrations; support for deferrable constraints; support for SQLite3; cleaner schema dumps.
8
9
 
9
- SchemaPlus::ForeignKeys is part of the [SchemaPlus](https://github.com/SchemaPlus/) family of Ruby on Rails ActiveRecord extension gems.
10
+ SchemaPlus::ForeignKeys is part of the [SchemaPlus](https://github.com/SchemaPlus/) family of Ruby on Rails ActiveRecord
11
+ extension gems.
10
12
 
11
- For extra convenience, see also [schema_auto_foreign_keys](https://github.com/SchemaPlus/schema_auto_foreign_keys), which creates foriegn key constraints automatically.
13
+ For extra convenience, see also [schema_auto_foreign_keys](https://github.com/SchemaPlus/schema_auto_foreign_keys),
14
+ which creates foriegn key constraints automatically.
12
15
 
13
16
 
14
17
  ## Installation
@@ -29,45 +32,50 @@ gem.add_dependency "schema_plus_foreign_keys" # in a .gemspec
29
32
  ### Migrations
30
33
 
31
34
  To declare a foreign key constraint for a column, use the `:foreign_key`
32
- option. The same options can be used with `t.integer`, `t.references`, `t.belongs_to`, `t.foreign_key`, `change_column`, and `add_foreign_key`:
35
+ option. The same options can be used with `t.integer`, `t.references`, `t.belongs_to`, `t.foreign_key`,
36
+ `change_column`, and `add_foreign_key`:
33
37
 
34
- t.integer :author_id, foreign_key: true # create a foreign_key to table "authors"
35
- t.integer :author_id, foreign_key: {} # create a foreign_key to table "authors"
36
- t.integer :author_id, foreign_key: false # don't create a constraint (this is the default)
38
+ t.references :author, foreign_key: true # create a foreign_key to table "authors"
39
+ t.references :author, foreign_key: {} # create a foreign_key to table "authors"
40
+ t.references :author, foreign_key: false # don't create a constraint (this is the default)
37
41
  t.integer :author, foreign_key: true # create a foreign_key to table "authors"
38
42
 
39
- t.integer :parent_id, foreign_key: true # special column parent_id defaults to referencing its own table
43
+ t.references :parent, foreign_key: true # special column parent_id defaults to referencing its own table
40
44
 
41
45
  Specify the target table and its primary key using the `:references` and `:primary_key`:
42
46
 
43
- t.integer :author_id, foreign_key: { references: :authors } # the default
47
+ t.references :author, foreign_key: { references: :authors } # the default
44
48
  t.integer :author, foreign_key: { references: :authors } # the default
45
- t.integer :author_id, foreign_key: { references: :people } # choose table name
46
- t.integer :author_id, foreign_key: { primary_key: :ssn] } # choose primary key
47
- t.integer :author_id, foreign_key: { references: :people, primary_key: :ssn] } # choose both
48
- t.integer :author_id, foreign_key: { references: [:people, :ssn] } # shortcut for both
49
- t.integer :author_id, foreign_key: { references: nil } # same as foreign_key: false
49
+ t.references :author, foreign_key: { references: :people } # choose table name
50
+ t.references :author, foreign_key: { primary_key: :ssn] } # choose primary key
51
+ t.references :author, foreign_key: { references: :people, primary_key: :ssn] } # choose both
52
+ t.references :author, foreign_key: { references: [:people, :ssn] } # shortcut for both
53
+ t.references :author, foreign_key: { references: nil } # same as foreign_key: false
50
54
 
51
- You can also specify other attributes:
55
+ You can also specify other attributes that are supported by Rails:
52
56
 
53
- t.integer :author_id, foreign_key: { name: "my_fk" } # override default auto-generated constraint name
54
- t.integer :author_id, foreign_key: { on_delete: :cascade }
55
- t.integer :author_id, foreign_key: { on_update: :set_null }
56
- t.integer :author_id, foreign_key: { deferrable: true }
57
- t.integer :author_id, foreign_key: { deferrable: :initially_deferred }
57
+ t.references :author, foreign_key: { name: "my_fk" } # override default auto-generated constraint name
58
+ t.references :author, foreign_key: { on_delete: :cascade }
59
+ t.references :author, foreign_key: { on_update: :set_null }
60
+
61
+ In addition, support for deferrable constraints is implemented:
62
+
63
+ t.references :author, foreign_key: { deferrable: true }
64
+ t.references :author, foreign_key: { deferrable: :initially_deferred }
58
65
 
59
66
  Of course the options can be combined:
60
67
 
61
- t.integer :author_id, foreign_key: { references: :people, primary_key: :ssn, name: "my_fk", on_delet: :no_action }
68
+ t.references :author, foreign_key: { references: :people, primary_key: :ssn, name: "my_fk", on_delet: :no_action }
62
69
 
63
70
 
64
71
  As a shorthand, all options except `:name` can be specified without placing
65
72
  them in a `foreign_key` hash, e.g.
66
73
 
67
- t.integer :author_id, on_delete: :cascade # shorthand for foreign_key: { on_delete: :cascade }
68
- t.integer :author_id, references: :people # shorthand for foreign_key: { references: :people }
74
+ t.references :author, on_delete: :cascade # shorthand for foreign_key: { on_delete: :cascade }
75
+ t.references :author, references: :people # shorthand for foreign_key: { references: :people }
69
76
 
70
- To remove a foreign key constraint, you can either change the column, specifying `foreign_key: false`, or use `migration.remove_foreign_key(table, column)`
77
+ To remove a foreign key constraint, you can either change the column, specifying `foreign_key: false`, or
78
+ use `migration.remove_foreign_key(table, column)`
71
79
 
72
80
  ### Introspection
73
81
 
@@ -128,11 +136,14 @@ foreign key options.
128
136
 
129
137
  ### Schema Dump
130
138
 
131
- For clarity (and because it's required for SQLite3), in the generated `schema_dump.rb` file, the foreign key definitions are inluded within the table definitions.
139
+ For clarity (and because it's required for SQLite3), in the generated `schema_dump.rb` file, the foreign key
140
+ definitions are included within the table definitions.
132
141
 
133
142
  This means that the tables are output sorted that a table is
134
- defined before others that depend on it. If, however, there are circularities in the
135
- foreign key relations, this won't be possible; In that case some table definitions will include comments indicating a "forward reference" to a table that's farther down in the file, and the constraint will be defined once that table is defined (this can never happen with SQLite3).
143
+ defined before others that depend on it. If, however, there are circular dependencies in the
144
+ foreign key relations, this won't be possible; In that case some table definitions will include comments indicating
145
+ a "forward reference" to a table that's farther down in the file, and the constraint will be defined once that table
146
+ is defined (this can never happen with SQLite3).
136
147
 
137
148
 
138
149
  ## Compatibility
@@ -141,15 +152,26 @@ SchemaPlus::ForeignKeys is tested on:
141
152
 
142
153
  <!-- SCHEMA_DEV: MATRIX - begin -->
143
154
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
144
- * ruby **2.3.1** with activerecord **4.2.0**, using **mysql2**, **sqlite3** or **postgresql**
145
- * ruby **2.3.1** with activerecord **4.2.1**, using **mysql2**, **sqlite3** or **postgresql**
146
- * ruby **2.3.1** with activerecord **4.2.6**, using **mysql2**, **sqlite3** or **postgresql**
147
- * ruby **2.3.1** with activerecord **5.0**, using **mysql2**, **sqlite3** or **postgresql**
155
+ * ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
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**
158
+ * ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
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**
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**
148
168
 
149
169
  <!-- SCHEMA_DEV: MATRIX - end -->
150
170
 
151
171
  ## History
152
172
 
173
+ * 1.0.0 - Drop Ruby < 2.5 and Rails < 5.2, adding Rails 6.0, and remove many deprecations
174
+ * 0.1.8 - Compatibility with ActiveRecord 5.1 and ActiveRecord 5.2.
153
175
  * 0.1.7 - Compatibility with ActiveRecord 5.0.
154
176
  * 0.1.6 - Missing require
155
177
  * 0.1.5 - Explicit gem dependencies
@@ -172,7 +194,7 @@ Some things to know about to help you develop and test:
172
194
  * **schema_dev**: SchemaPlus::ForeignKeys uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
173
195
  facilitate running rspec tests on the matrix of ruby, activerecord, and database
174
196
  versions that the gem supports, both locally and on
175
- [travis-ci](http://travis-ci.org/SchemaPlus/schema_plus_foreign_keys)
197
+ [github actions](https://github.com/SchemaPlus/schema_plus_foreign_keys/actions)
176
198
 
177
199
  To to run rspec locally on the full matrix, do:
178
200
 
@@ -184,7 +206,6 @@ Some things to know about to help you develop and test:
184
206
  The matrix of configurations is specified in `schema_dev.yml` in
185
207
  the project root.
186
208
 
187
-
188
209
  <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
189
210
 
190
211
  <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - begin -->
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
4
6
  require 'schema_dev/tasks'
5
7
 
6
- task :default => :spec
8
+ task default: :spec
7
9
 
8
10
  require 'rspec/core/rake_task'
9
11
  RSpec::Core::RakeTask.new(:spec)
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gemspec :path => File.expand_path('..', __FILE__)
2
+ gemspec path: File.expand_path('..', __FILE__)
3
3
 
4
4
  File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 5.2.0.beta0", "< 5.3"
@@ -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
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
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", ">= 6.0", "< 6.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
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
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", ">= 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
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
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
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
10
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::ForeignKeys
2
4
  module ActiveRecord
3
5
 
@@ -1,8 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus
2
4
  module Core
3
5
  module ActiveRecord
4
6
  module ConnectionAdapters
5
- 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
6
19
  module SchemaCreation
7
20
 
8
21
  def visit_ForeignKeyDefinition(o)
@@ -10,20 +23,9 @@ module SchemaPlus
10
23
  # conversion of ForeignKeyDefinitions to SQL
11
24
  o.to_sql
12
25
  end
13
-
14
- # The TableDefinition::foreign_keys attribute contains ForeignKeyDefinitions instead of
15
- # [to_table, options] tuples when using schema_plus_foreign_keys.
16
- # This function happily accepts to_table and options arguments anyway, so we just ignore
17
- # all arguments and treat to_table as the ForeignKeyDefinition and convert it to SQL
18
- # directly.
19
- def foreign_key_in_create(from_table, to_table, options)
20
- accept to_table # This is the ForeignKeyDefinition
21
- end
22
-
23
26
  end
24
27
  end
25
28
  end
26
29
  end
27
30
  end
28
31
  end
29
-