schema_plus_foreign_keys 0.1.8 → 1.0.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 +173 -0
- data/.gitignore +1 -0
- data/.simplecov +20 -0
- data/Gemfile +4 -1
- data/README.md +43 -27
- data/Rakefile +3 -1
- data/gemfiles/Gemfile.base +1 -1
- data/gemfiles/activerecord-5.2/Gemfile.base +2 -1
- data/gemfiles/activerecord-5.2/Gemfile.mysql2 +2 -2
- data/gemfiles/activerecord-5.2/Gemfile.postgresql +2 -2
- data/gemfiles/activerecord-5.2/Gemfile.sqlite3 +3 -3
- data/gemfiles/activerecord-6.0/Gemfile.base +4 -0
- data/gemfiles/activerecord-6.0/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-6.0/Gemfile.postgresql +10 -0
- data/gemfiles/{activerecord-4.2.0 → activerecord-6.0}/Gemfile.sqlite3 +3 -3
- 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-4.2.1 → activerecord-6.1}/Gemfile.sqlite3 +3 -3
- 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-4.2.6 → activerecord-7.0}/Gemfile.sqlite3 +3 -3
- data/lib/schema_plus/foreign_keys/active_record/base.rb +2 -0
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract/schema_creation.rb +14 -12
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb +7 -47
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/foreign_key_definition.rb +4 -35
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/mysql2_adapter.rb +15 -16
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/postgresql_adapter.rb +8 -6
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb +8 -6
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/table_definition.rb +7 -46
- data/lib/schema_plus/foreign_keys/active_record/migration/command_recorder.rb +4 -2
- data/lib/schema_plus/foreign_keys/middleware/dumper.rb +5 -3
- data/lib/schema_plus/foreign_keys/middleware/migration.rb +13 -5
- data/lib/schema_plus/foreign_keys/middleware/model.rb +2 -0
- data/lib/schema_plus/foreign_keys/middleware/mysql.rb +3 -1
- data/lib/schema_plus/foreign_keys/middleware/sql.rb +2 -16
- data/lib/schema_plus/foreign_keys/version.rb +3 -1
- data/lib/schema_plus/foreign_keys.rb +2 -2
- data/lib/schema_plus_foreign_keys.rb +2 -0
- data/schema_dev.yml +7 -6
- data/schema_plus_foreign_keys.gemspec +9 -9
- data/spec/deprecation_spec.rb +11 -110
- data/spec/foreign_key_definition_spec.rb +5 -3
- data/spec/foreign_key_spec.rb +22 -20
- data/spec/migration_spec.rb +36 -60
- data/spec/named_schemas_spec.rb +16 -14
- data/spec/schema_dumper_spec.rb +15 -15
- data/spec/spec_helper.rb +5 -4
- data/spec/support/reference.rb +3 -2
- metadata +35 -99
- data/.travis.yml +0 -33
- data/gemfiles/activerecord-4.2.0/Gemfile.base +0 -3
- data/gemfiles/activerecord-4.2.0/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-4.2.0/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-4.2.1/Gemfile.base +0 -3
- data/gemfiles/activerecord-4.2.1/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-4.2.1/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-4.2.6/Gemfile.base +0 -3
- data/gemfiles/activerecord-4.2.6/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-4.2.6/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-5.0/Gemfile.base +0 -3
- data/gemfiles/activerecord-5.0/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-5.0/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-5.0/Gemfile.sqlite3 +0 -10
- data/gemfiles/activerecord-5.1/Gemfile.base +0 -3
- data/gemfiles/activerecord-5.1/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-5.1/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-5.1/Gemfile.sqlite3 +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 245fb0b005d4ddb0375185c9eb8b5831746faa40f16e9bd1202fbc31b1ef12ea
|
4
|
+
data.tar.gz: 1ee38608fe9b94b50826468fae70f976acd20d0f091364253440517587e5a377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813e24f5945c866e42df2717c4378a21ff3f9eb8847df95b5c133af98deca474a1fc2ff6e6c8433b54ec53ddd26a2507351bb6dd2aa0dff6e4f9cd6942fa886c
|
7
|
+
data.tar.gz: d64a27dd160a3afc7fb9dc930298905cc617092bcc781f1f87b7f4b222cd43301958993c7897c9cd0ca4a046cbe0400ff68e781db865596031b81ea9d5ddebfd
|
@@ -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
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
|
-
|
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://
|
3
|
-
[![Coverage Status](https://
|
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
|
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
|
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),
|
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,7 +32,8 @@ 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`,
|
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
38
|
t.references :author, foreign_key: true # create a foreign_key to table "authors"
|
35
39
|
t.references :author, foreign_key: {} # create a foreign_key to table "authors"
|
@@ -70,7 +74,8 @@ them in a `foreign_key` hash, e.g.
|
|
70
74
|
t.references :author, on_delete: :cascade # shorthand for foreign_key: { on_delete: :cascade }
|
71
75
|
t.references :author, references: :people # shorthand for foreign_key: { references: :people }
|
72
76
|
|
73
|
-
To remove a foreign key constraint, you can either change the column, specifying `foreign_key: false`, or
|
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)`
|
74
79
|
|
75
80
|
### Introspection
|
76
81
|
|
@@ -131,11 +136,14 @@ foreign key options.
|
|
131
136
|
|
132
137
|
### Schema Dump
|
133
138
|
|
134
|
-
For clarity (and because it's required for SQLite3), in the generated `schema_dump.rb` file, the foreign key
|
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.
|
135
141
|
|
136
142
|
This means that the tables are output sorted that a table is
|
137
|
-
defined before others that depend on it. If, however, there are
|
138
|
-
foreign key relations, this won't be possible; In that case some table definitions will include comments indicating
|
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).
|
139
147
|
|
140
148
|
|
141
149
|
## Compatibility
|
@@ -144,26 +152,35 @@ SchemaPlus::ForeignKeys is tested on:
|
|
144
152
|
|
145
153
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
146
154
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
147
|
-
* ruby **2.
|
148
|
-
* ruby **2.
|
149
|
-
* ruby **2.
|
150
|
-
* ruby **2.
|
151
|
-
* ruby **2.
|
152
|
-
* ruby **2.
|
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**
|
153
168
|
|
154
169
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
155
170
|
|
156
171
|
## History
|
157
172
|
|
158
|
-
*
|
159
|
-
* 0.
|
160
|
-
* 0.1.
|
161
|
-
* 0.1.
|
162
|
-
* 0.1.
|
163
|
-
* 0.1.
|
164
|
-
* 0.1.
|
165
|
-
* 0.1.
|
166
|
-
* 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*
|
167
184
|
|
168
185
|
## Development & Testing
|
169
186
|
|
@@ -178,7 +195,7 @@ Some things to know about to help you develop and test:
|
|
178
195
|
* **schema_dev**: SchemaPlus::ForeignKeys uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
|
179
196
|
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
180
197
|
versions that the gem supports, both locally and on
|
181
|
-
[
|
198
|
+
[github actions](https://github.com/SchemaPlus/schema_plus_foreign_keys/actions)
|
182
199
|
|
183
200
|
To to run rspec locally on the full matrix, do:
|
184
201
|
|
@@ -190,7 +207,6 @@ Some things to know about to help you develop and test:
|
|
190
207
|
The matrix of configurations is specified in `schema_dev.yml` in
|
191
208
|
the project root.
|
192
209
|
|
193
|
-
|
194
210
|
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
|
195
211
|
|
196
212
|
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - begin -->
|
data/Rakefile
CHANGED
data/gemfiles/Gemfile.base
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
eval
|
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,5 +1,5 @@
|
|
1
|
-
|
2
|
-
eval
|
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,5 +1,5 @@
|
|
1
|
-
|
2
|
-
eval
|
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,5 +1,5 @@
|
|
1
|
-
|
2
|
-
eval
|
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
|
data/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract/schema_creation.rb
CHANGED
@@ -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
|
-
|
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
|
-
|