schema_auto_foreign_keys 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/prs.yml +134 -0
- data/.simplecov +19 -0
- data/Gemfile +2 -1
- data/README.md +10 -8
- data/Rakefile +1 -1
- data/gemfiles/Gemfile.base +1 -1
- data/gemfiles/activerecord-5.2/Gemfile.base +4 -0
- data/gemfiles/activerecord-5.2/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-5.2/Gemfile.postgresql +10 -0
- data/gemfiles/{activerecord-4.2 → 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-5.0 → activerecord-6.0}/Gemfile.sqlite3 +3 -3
- data/lib/schema_auto_foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/schema_auto_foreign_keys/middleware/migration.rb +3 -3
- data/lib/schema_auto_foreign_keys/middleware/schema.rb +1 -1
- data/lib/schema_auto_foreign_keys/version.rb +1 -1
- data/lib/schema_auto_foreign_keys.rb +2 -3
- data/schema_auto_foreign_keys.gemspec +7 -8
- data/schema_dev.yml +5 -3
- data/spec/migration_spec.rb +75 -71
- data/spec/schema_spec.rb +7 -7
- data/spec/spec_helper.rb +2 -3
- metadata +29 -71
- data/.travis.yml +0 -21
- data/gemfiles/activerecord-4.2/Gemfile.base +0 -3
- data/gemfiles/activerecord-4.2/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-4.2/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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fa12ac616f5ce5677d2c2bea13ad20164b80adf764066679627ef3e2eec1409d
|
4
|
+
data.tar.gz: 8188e920c5d2ba40309203bccba5665ca332fe0b12887c130688aa9894143d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cef6379c1877ec78c61f0e6a8a807b6892c6ce2396a1e59b15fd0f00b5f1d35b0fc621469f6aaf131b12bd98a238aa955460c70ae597a3d167714716ce26456
|
7
|
+
data.tar.gz: 11d4059f62fca77a85d7c59fa0a91795d800be76dd0a57be95d9257e7147304c567b2176fb34ebe36ac0bbaca4c1d9259327bad47b0b8ff4aace56e0d084fb5c
|
@@ -0,0 +1,134 @@
|
|
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
|
+
activerecord:
|
26
|
+
- '5.2'
|
27
|
+
- '6.0'
|
28
|
+
db:
|
29
|
+
- mysql2
|
30
|
+
- sqlite3
|
31
|
+
- skip
|
32
|
+
dbversion:
|
33
|
+
- skip
|
34
|
+
exclude:
|
35
|
+
- ruby: '3.0'
|
36
|
+
activerecord: '5.2'
|
37
|
+
- db: skip
|
38
|
+
dbversion: skip
|
39
|
+
include:
|
40
|
+
- ruby: '2.5'
|
41
|
+
activerecord: '5.2'
|
42
|
+
db: postgresql
|
43
|
+
dbversion: '9.6'
|
44
|
+
- ruby: '2.5'
|
45
|
+
activerecord: '6.0'
|
46
|
+
db: postgresql
|
47
|
+
dbversion: '9.6'
|
48
|
+
- ruby: '2.7'
|
49
|
+
activerecord: '5.2'
|
50
|
+
db: postgresql
|
51
|
+
dbversion: '9.6'
|
52
|
+
- ruby: '2.7'
|
53
|
+
activerecord: '6.0'
|
54
|
+
db: postgresql
|
55
|
+
dbversion: '9.6'
|
56
|
+
- ruby: '3.0'
|
57
|
+
activerecord: '6.0'
|
58
|
+
db: postgresql
|
59
|
+
dbversion: '9.6'
|
60
|
+
env:
|
61
|
+
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
|
62
|
+
MYSQL_DB_HOST: 127.0.0.1
|
63
|
+
MYSQL_DB_USER: root
|
64
|
+
MYSQL_DB_PASS: database
|
65
|
+
POSTGRESQL_DB_HOST: 127.0.0.1
|
66
|
+
POSTGRESQL_DB_USER: schema_plus_test
|
67
|
+
POSTGRESQL_DB_PASS: database
|
68
|
+
steps:
|
69
|
+
- uses: actions/checkout@v2
|
70
|
+
- name: Set up Ruby
|
71
|
+
uses: ruby/setup-ruby@v1
|
72
|
+
with:
|
73
|
+
ruby-version: "${{ matrix.ruby }}"
|
74
|
+
bundler-cache: true
|
75
|
+
- name: Run bundle update
|
76
|
+
run: bundle update
|
77
|
+
- name: Start Mysql
|
78
|
+
if: matrix.db == 'mysql2'
|
79
|
+
run: |
|
80
|
+
docker run --rm --detach \
|
81
|
+
-e MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASS \
|
82
|
+
-p 3306:3306 \
|
83
|
+
--health-cmd "mysqladmin ping --host=127.0.0.1 --password=$MYSQL_DB_PASS --silent" \
|
84
|
+
--health-interval 5s \
|
85
|
+
--health-timeout 5s \
|
86
|
+
--health-retries 5 \
|
87
|
+
--name database mysql:5.6
|
88
|
+
- name: Start Postgresql
|
89
|
+
if: matrix.db == 'postgresql'
|
90
|
+
run: |
|
91
|
+
docker run --rm --detach \
|
92
|
+
-e POSTGRES_USER=$POSTGRESQL_DB_USER \
|
93
|
+
-e POSTGRES_PASSWORD=$POSTGRESQL_DB_PASS \
|
94
|
+
-p 5432:5432 \
|
95
|
+
--health-cmd "pg_isready -q" \
|
96
|
+
--health-interval 5s \
|
97
|
+
--health-timeout 5s \
|
98
|
+
--health-retries 5 \
|
99
|
+
--name database postgres:${{ matrix.dbversion }}
|
100
|
+
- name: Wait for database to start
|
101
|
+
if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
|
102
|
+
run: |
|
103
|
+
COUNT=0
|
104
|
+
ATTEMPTS=20
|
105
|
+
until [[ $COUNT -eq $ATTEMPTS ]]; do
|
106
|
+
[ "$(docker inspect -f {{.State.Health.Status}} database)" == "healthy" ] && break
|
107
|
+
echo $(( COUNT++ )) > /dev/null
|
108
|
+
sleep 2
|
109
|
+
done
|
110
|
+
- name: Create testing database
|
111
|
+
if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
|
112
|
+
run: bundle exec rake create_ci_database
|
113
|
+
- name: Run tests
|
114
|
+
run: bundle exec rake spec
|
115
|
+
- name: Shutdown database
|
116
|
+
if: always() && (matrix.db == 'postgresql' || matrix.db == 'mysql2')
|
117
|
+
run: docker stop database
|
118
|
+
- name: Coveralls Parallel
|
119
|
+
if: "${{ !env.ACT }}"
|
120
|
+
uses: coverallsapp/github-action@master
|
121
|
+
with:
|
122
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
123
|
+
flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}-${{ matrix.db }}-${{ matrix.dbversion }}
|
124
|
+
parallel: true
|
125
|
+
finish:
|
126
|
+
needs: test
|
127
|
+
runs-on: ubuntu-latest
|
128
|
+
steps:
|
129
|
+
- name: Coveralls Finished
|
130
|
+
if: "${{ !env.ACT }}"
|
131
|
+
uses: coverallsapp/github-action@master
|
132
|
+
with:
|
133
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
134
|
+
parallel-finished: true
|
data/.simplecov
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
SimpleCov.configure do
|
2
|
+
enable_coverage :branch
|
3
|
+
add_filter '/spec/'
|
4
|
+
|
5
|
+
add_group 'Binaries', '/bin/'
|
6
|
+
add_group 'Libraries', '/lib/'
|
7
|
+
|
8
|
+
if ENV['CI']
|
9
|
+
require 'simplecov-lcov'
|
10
|
+
|
11
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
12
|
+
c.report_with_single_file = true
|
13
|
+
c.single_report_path = 'coverage/lcov.info'
|
14
|
+
end
|
15
|
+
|
16
|
+
formatter SimpleCov::Formatter::LcovFormatter
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
data/Gemfile
CHANGED
@@ -2,4 +2,5 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
5
|
+
gemfile_local = File.expand_path '../Gemfile.local', __FILE__
|
6
|
+
eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/schema_auto_foreign_keys.svg)](http://badge.fury.io/rb/schema_auto_foreign_keys)
|
2
|
-
[![Build Status](https://
|
3
|
-
[![Coverage Status](https://
|
4
|
-
[![Dependency Status](https://gemnasium.com/lomba/schema_auto_foreign_keys.svg)](https://gemnasium.com/SchemaPlus/schema_auto_foreign_keys)
|
2
|
+
[![Build Status](https://github.com/SchemaPlus/schema_auto_foreign_keys/actions/workflows/prs.yml/badge.svg)](https://github.com/SchemaPlus/schema_auto_foreign_keys/actions)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/SchemaPlus/schema_auto_foreign_keys/badge.svg?branch=master)](https://coveralls.io/github/SchemaPlus/schema_auto_foreign_keys?branch=master)
|
5
4
|
|
6
5
|
# SchemaAutoForeignKeys
|
7
6
|
|
@@ -36,7 +35,7 @@ There is actually one difference between an auto-created index and specifying `i
|
|
36
35
|
If you need specific paramaters other than the default, you can of course specify them:
|
37
36
|
|
38
37
|
```ruby
|
39
|
-
t.integer :user_id, index: :unique # "has one" relationship between users and this
|
38
|
+
t.integer :user_id, index: :unique # "has one" relationship between users and this
|
40
39
|
model
|
41
40
|
t.integer :user_id, on_delete: :cascade
|
42
41
|
```
|
@@ -88,8 +87,11 @@ SchemaAutoForeignKeys is tested on:
|
|
88
87
|
|
89
88
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
90
89
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
91
|
-
* ruby **2.
|
92
|
-
* ruby **2.
|
90
|
+
* ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
91
|
+
* ruby **2.5** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
92
|
+
* ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
93
|
+
* ruby **2.7** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
94
|
+
* ruby **3.0** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
93
95
|
|
94
96
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
95
97
|
|
@@ -103,6 +105,7 @@ SQlite3 doesn't support renaming the auto-index whtn the table name changes.
|
|
103
105
|
|
104
106
|
## History
|
105
107
|
|
108
|
+
* 1.0.0 - Drop Ruby < 2.5 and Rails < 5.2, add Rails 6.0, and remove many deprecations
|
106
109
|
* 0.1.3 - AR5 (Rails 5) Support
|
107
110
|
* 0.1.2 - Missing require
|
108
111
|
* 0.1.1 - Explicit gem dependencies
|
@@ -121,7 +124,7 @@ Some things to know about to help you develop and test:
|
|
121
124
|
* **schema_dev**: SchemaAutoForeignKeys uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
|
122
125
|
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
123
126
|
versions that the gem supports, both locally and on
|
124
|
-
[
|
127
|
+
[github actions](https://github.com/SchemaPlus/schema_auto_foreign_keys/actions)
|
125
128
|
|
126
129
|
To to run rspec locally on the full matrix, do:
|
127
130
|
|
@@ -133,7 +136,6 @@ Some things to know about to help you develop and test:
|
|
133
136
|
The matrix of configurations is specified in `schema_dev.yml` in
|
134
137
|
the project root.
|
135
138
|
|
136
|
-
|
137
139
|
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
|
138
140
|
|
139
141
|
|
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
|
@@ -7,7 +7,7 @@ module SchemaAutoForeignKeys
|
|
7
7
|
module Sqlite3Adapter
|
8
8
|
|
9
9
|
def copy_table(*args, &block)
|
10
|
-
fk_override = { :
|
10
|
+
fk_override = { auto_create: false, auto_index: false }
|
11
11
|
save = Hash[fk_override.keys.collect{|key| [key, SchemaPlus::ForeignKeys.config.send(key)]}]
|
12
12
|
begin
|
13
13
|
SchemaPlus::ForeignKeys.config.update_attributes(fk_override)
|
@@ -23,14 +23,14 @@ module SchemaAutoForeignKeys
|
|
23
23
|
oldname = env.table_name
|
24
24
|
indexes = env.connection.indexes(newname)
|
25
25
|
env.connection.foreign_keys(newname).each do |fk|
|
26
|
-
index = indexes.find
|
26
|
+
index = indexes.find { |it| it.name == AutoCreate.auto_index_name(oldname, fk.column) }
|
27
27
|
env.connection.rename_index(newname, index.name, AutoCreate.auto_index_name(newname, index.columns)) if index
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
module AutoCreate
|
35
35
|
def before(env)
|
36
36
|
config ||= env.caller.try(:schema_plus_foreign_keys_config) || SchemaPlus::ForeignKeys.config
|
@@ -69,7 +69,7 @@ module SchemaAutoForeignKeys
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def remove_auto_index(env)
|
72
|
-
env.caller.remove_index(env.table_name, :
|
72
|
+
env.caller.remove_index(env.table_name, name: auto_index_name(env), column: env.column_name, if_exists: true)
|
73
73
|
end
|
74
74
|
|
75
75
|
def auto_index_name(env)
|
@@ -3,7 +3,7 @@ module SchemaAutoForeignKeys
|
|
3
3
|
module Schema
|
4
4
|
module Define
|
5
5
|
def around(env)
|
6
|
-
fk_override = { :
|
6
|
+
fk_override = { auto_create: false, auto_index: false }
|
7
7
|
save = Hash[fk_override.keys.collect{|key| [key, SchemaPlus::ForeignKeys.config.send(key)]}]
|
8
8
|
begin
|
9
9
|
SchemaPlus::ForeignKeys.config.update_attributes(fk_override)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'schema_plus/foreign_keys'
|
2
2
|
require 'schema_plus/indexes'
|
3
|
-
require 'its-it'
|
4
3
|
|
5
4
|
require_relative 'schema_auto_foreign_keys/middleware/migration'
|
6
5
|
require_relative 'schema_auto_foreign_keys/middleware/schema'
|
@@ -19,14 +18,14 @@ class SchemaPlus::ForeignKeys::Config
|
|
19
18
|
#
|
20
19
|
# Whether to automatically create foreign key constraints for columns
|
21
20
|
# suffixed with +_id+. Boolean, default is +true+.
|
22
|
-
has_value :auto_create, :
|
21
|
+
has_value :auto_create, klass: :boolean, default: true
|
23
22
|
|
24
23
|
##
|
25
24
|
# :attr_accessor: auto_index
|
26
25
|
#
|
27
26
|
# Whether to automatically create indexes when creating foreign key constraints for columns.
|
28
27
|
# Boolean, default is +true+.
|
29
|
-
has_value :auto_index, :
|
28
|
+
has_value :auto_index, klass: :boolean, default: true
|
30
29
|
end
|
31
30
|
|
32
31
|
SchemaMonkey.register SchemaAutoForeignKeys
|
@@ -18,14 +18,13 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.
|
22
|
-
gem.add_dependency "schema_plus_indexes", "~> 0.2"
|
23
|
-
gem.add_dependency "its-it", "~> 1.2"
|
21
|
+
gem.required_ruby_version = ">= 2.5.0"
|
24
22
|
|
25
|
-
gem.
|
26
|
-
gem.
|
23
|
+
gem.add_dependency "schema_plus_foreign_keys", "~> 1.0.0"
|
24
|
+
gem.add_dependency "schema_plus_indexes", "~> 1.0.0"
|
25
|
+
|
26
|
+
gem.add_development_dependency "bundler"
|
27
|
+
gem.add_development_dependency "rake", "~> 13.0"
|
27
28
|
gem.add_development_dependency "rspec", "~> 3.0"
|
28
|
-
gem.add_development_dependency "schema_dev", "~>
|
29
|
-
gem.add_development_dependency "simplecov"
|
30
|
-
gem.add_development_dependency "simplecov-gem-profile"
|
29
|
+
gem.add_development_dependency "schema_dev", "~> 4.1"
|
31
30
|
end
|
data/schema_dev.yml
CHANGED
data/spec/migration_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe ActiveRecord::Migration do
|
|
7
7
|
define_schema do
|
8
8
|
|
9
9
|
create_table :users do |t|
|
10
|
-
t.string :login, :
|
10
|
+
t.string :login, index: { unique: true}
|
11
11
|
end
|
12
12
|
|
13
13
|
create_table :members do |t|
|
@@ -17,8 +17,8 @@ describe ActiveRecord::Migration do
|
|
17
17
|
create_table :comments do |t|
|
18
18
|
t.string :content
|
19
19
|
t.integer :user
|
20
|
-
t.
|
21
|
-
t.foreign_key :
|
20
|
+
t.bigint :user_id
|
21
|
+
t.foreign_key :users, column: :user_id
|
22
22
|
end
|
23
23
|
|
24
24
|
create_table :posts do |t|
|
@@ -28,10 +28,13 @@ describe ActiveRecord::Migration do
|
|
28
28
|
class User < ::ActiveRecord::Base ; end
|
29
29
|
class Post < ::ActiveRecord::Base ; end
|
30
30
|
class Comment < ::ActiveRecord::Base ; end
|
31
|
+
User.reset_column_information
|
32
|
+
Post.reset_column_information
|
33
|
+
Comment.reset_column_information
|
31
34
|
end
|
32
35
|
|
33
36
|
around(:each) do |example|
|
34
|
-
with_fk_config(:
|
37
|
+
with_fk_config(auto_create: true, auto_index: true) { example.run }
|
35
38
|
end
|
36
39
|
|
37
40
|
context "when table is created" do
|
@@ -42,14 +45,14 @@ describe ActiveRecord::Migration do
|
|
42
45
|
|
43
46
|
it "creates auto foreign keys" do
|
44
47
|
create_table(@model) do |t|
|
45
|
-
t.
|
48
|
+
t.bigint :user_id
|
46
49
|
end
|
47
50
|
expect(@model).to reference(:users, :id).on(:user_id)
|
48
51
|
end
|
49
52
|
|
50
53
|
it "respects explicit foreign key" do
|
51
54
|
create_table(@model) do |t|
|
52
|
-
t.
|
55
|
+
t.bigint :author_id, foreign_key: { references: :users }
|
53
56
|
end
|
54
57
|
expect(@model).to reference(:users, :id).on(:author_id)
|
55
58
|
expect(@model).to have_index.on(:author_id)
|
@@ -57,7 +60,7 @@ describe ActiveRecord::Migration do
|
|
57
60
|
|
58
61
|
it "suppresses auto foreign key" do
|
59
62
|
create_table(@model) do |t|
|
60
|
-
t.
|
63
|
+
t.bigint :member_id, foreign_key: false
|
61
64
|
end
|
62
65
|
expect(@model).not_to reference.on(:member_id)
|
63
66
|
expect(@model).not_to have_index.on(:member_id)
|
@@ -65,7 +68,7 @@ describe ActiveRecord::Migration do
|
|
65
68
|
|
66
69
|
it "suppresses auto foreign key using shortcut" do
|
67
70
|
create_table(@model) do |t|
|
68
|
-
t.
|
71
|
+
t.bigint :member_id, references: nil
|
69
72
|
end
|
70
73
|
expect(@model).not_to reference.on(:member_id)
|
71
74
|
expect(@model).not_to have_index.on(:member_id)
|
@@ -85,12 +88,12 @@ describe ActiveRecord::Migration do
|
|
85
88
|
end
|
86
89
|
|
87
90
|
it "does not create a foreign_key if polymorphic" do
|
88
|
-
create_reference(reftype, :post, :
|
91
|
+
create_reference(reftype, :post, polymorphic: true)
|
89
92
|
expect(@model).not_to reference(:posts, :id).on(:post_id)
|
90
93
|
end
|
91
94
|
|
92
|
-
it "does not create a foreign_key with :
|
93
|
-
create_reference(reftype, :post, :
|
95
|
+
it "does not create a foreign_key with foreign_key: false" do
|
96
|
+
create_reference(reftype, :post, foreign_key: false)
|
94
97
|
expect(@model).not_to reference(:posts, :id).on(:post_id)
|
95
98
|
end
|
96
99
|
|
@@ -100,25 +103,25 @@ describe ActiveRecord::Migration do
|
|
100
103
|
end
|
101
104
|
|
102
105
|
it "should create exactly one index explicitly (#157)" do
|
103
|
-
create_reference(reftype, :post, :
|
106
|
+
create_reference(reftype, :post, index: true)
|
104
107
|
expect(@model).to have_index.on(:post_id)
|
105
108
|
end
|
106
109
|
|
107
110
|
it "should respect :unique (#157)" do
|
108
|
-
create_reference(reftype, :post, :
|
111
|
+
create_reference(reftype, :post, index: :unique)
|
109
112
|
expect(@model).to have_unique_index.on(:post_id)
|
110
113
|
end
|
111
114
|
|
112
115
|
it "should create a two-column index if polymophic and index requested" do
|
113
|
-
create_reference(reftype, :post, :
|
116
|
+
create_reference(reftype, :post, polymorphic: true, index: true)
|
114
117
|
expect(@model).to have_index.on([:post_id, :post_type])
|
115
118
|
end
|
116
119
|
|
117
120
|
protected
|
118
121
|
|
119
|
-
def create_reference(reftype, column_name,
|
122
|
+
def create_reference(reftype, column_name, **kwargs)
|
120
123
|
create_table(@model) do |t|
|
121
|
-
t.send reftype, column_name,
|
124
|
+
t.send reftype, column_name, **kwargs.merge(type: :bigint)
|
122
125
|
end
|
123
126
|
end
|
124
127
|
|
@@ -127,9 +130,9 @@ describe ActiveRecord::Migration do
|
|
127
130
|
|
128
131
|
it "creates auto-index on foreign keys only" do
|
129
132
|
create_table(@model) do |t|
|
130
|
-
t.
|
131
|
-
t.
|
132
|
-
t.
|
133
|
+
t.bigint :user_id
|
134
|
+
t.bigint :application_id, references: nil
|
135
|
+
t.bigint :state
|
133
136
|
end
|
134
137
|
expect(@model).to have_index.on(:user_id)
|
135
138
|
expect(@model).not_to have_index.on(:application_id)
|
@@ -141,52 +144,52 @@ describe ActiveRecord::Migration do
|
|
141
144
|
column = ("co"*15 + "_id")
|
142
145
|
expect {
|
143
146
|
ActiveRecord::Migration.create_table table do |t|
|
144
|
-
t.
|
147
|
+
t.bigint column, foreign_key: { references: :members, name: "verylong" }
|
145
148
|
end
|
146
149
|
}.not_to raise_error
|
147
150
|
expect(ActiveRecord::Base.connection.indexes(table).first.columns.first).to eq column
|
148
151
|
end
|
149
152
|
|
150
153
|
it "overrides foreign key auto_create positively" do
|
151
|
-
with_fk_config(:
|
152
|
-
create_table @model, :
|
153
|
-
t.
|
154
|
+
with_fk_config(auto_create: false) do
|
155
|
+
create_table @model, foreign_keys: { auto_create: true } do |t|
|
156
|
+
t.bigint :user_id
|
154
157
|
end
|
155
158
|
expect(@model).to reference(:users, :id).on(:user_id)
|
156
159
|
end
|
157
160
|
end
|
158
161
|
|
159
162
|
it "overrides foreign key auto_create negatively" do
|
160
|
-
with_fk_config(:
|
161
|
-
create_table @model, :
|
162
|
-
t.
|
163
|
+
with_fk_config(auto_create: true) do
|
164
|
+
create_table @model, foreign_keys: { auto_create: false } do |t|
|
165
|
+
t.bigint :user_id
|
163
166
|
end
|
164
167
|
expect(@model).not_to reference.on(:user_id)
|
165
168
|
end
|
166
169
|
end
|
167
170
|
|
168
171
|
it "overrides foreign key auto_index positively" do
|
169
|
-
with_fk_config(:
|
170
|
-
create_table @model, :
|
171
|
-
t.
|
172
|
+
with_fk_config(auto_index: false) do
|
173
|
+
create_table @model, foreign_keys: { auto_index: true } do |t|
|
174
|
+
t.bigint :user_id
|
172
175
|
end
|
173
176
|
expect(@model).to have_index.on(:user_id)
|
174
177
|
end
|
175
178
|
end
|
176
179
|
|
177
|
-
it "overrides foreign key auto_index negatively", :
|
178
|
-
with_fk_config(:
|
179
|
-
create_table @model, :
|
180
|
-
t.
|
180
|
+
it "overrides foreign key auto_index negatively", mysql: :skip do
|
181
|
+
with_fk_config(auto_index: true) do
|
182
|
+
create_table @model, foreign_keys: { auto_index: false } do |t|
|
183
|
+
t.bigint :user_id
|
181
184
|
end
|
182
185
|
expect(@model).not_to have_index.on(:user_id)
|
183
186
|
end
|
184
187
|
end
|
185
188
|
|
186
|
-
it "disables auto-index for a column", :
|
187
|
-
with_fk_config(:
|
189
|
+
it "disables auto-index for a column", mysql: :skip do
|
190
|
+
with_fk_config(auto_index: true) do
|
188
191
|
create_table @model do |t|
|
189
|
-
t.
|
192
|
+
t.bigint :user_id, index: false
|
190
193
|
end
|
191
194
|
expect(@model).not_to have_index.on(:user_id)
|
192
195
|
end
|
@@ -194,7 +197,7 @@ describe ActiveRecord::Migration do
|
|
194
197
|
|
195
198
|
end
|
196
199
|
|
197
|
-
context "when table is changed", :
|
200
|
+
context "when table is changed", sqlite3: :skip do
|
198
201
|
before(:each) do
|
199
202
|
@model = Post
|
200
203
|
end
|
@@ -202,8 +205,10 @@ describe ActiveRecord::Migration do
|
|
202
205
|
suffix = bulk ? ' with :bulk option' : ""
|
203
206
|
|
204
207
|
it "auto creates a foreign key constraint"+suffix do
|
205
|
-
|
206
|
-
|
208
|
+
# https://github.com/rails/rails/pull/35958 was never backported to Rails 5.2
|
209
|
+
skip("Not supported on MySQL with Rails 5.2") if bulk && ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::Base.connection.adapter_name == "Mysql2"
|
210
|
+
change_table(@model, bulk: bulk) do |t|
|
211
|
+
t.bigint :user_id
|
207
212
|
end
|
208
213
|
expect(@model).to reference(:users, :id).on(:user_id)
|
209
214
|
end
|
@@ -211,14 +216,14 @@ describe ActiveRecord::Migration do
|
|
211
216
|
context "migrate down" do
|
212
217
|
it "removes an auto foreign key and index"+suffix do
|
213
218
|
create_table Comment do |t|
|
214
|
-
t.
|
219
|
+
t.bigint :user_id
|
215
220
|
end
|
216
221
|
expect(Comment).to reference(:users, :id).on(:user_id)
|
217
222
|
expect(Comment).to have_index.on(:user_id)
|
218
223
|
migration = Class.new ::ActiveRecord::Migration.latest_version do
|
219
224
|
define_method(:change) {
|
220
|
-
change_table("comments", :
|
221
|
-
t.
|
225
|
+
change_table("comments", bulk: bulk) do |t|
|
226
|
+
t.bigint :user_id
|
222
227
|
end
|
223
228
|
}
|
224
229
|
end
|
@@ -231,83 +236,83 @@ describe ActiveRecord::Migration do
|
|
231
236
|
end
|
232
237
|
end
|
233
238
|
|
234
|
-
context "when table is renamed", :
|
239
|
+
context "when table is renamed", postgresql: :only do
|
235
240
|
|
236
241
|
before(:each) do
|
237
242
|
@model = Comment
|
238
243
|
create_table @model do |t|
|
239
|
-
t.
|
240
|
-
t.
|
244
|
+
t.bigint :user_id
|
245
|
+
t.bigint :xyz, index: true
|
241
246
|
end
|
242
247
|
ActiveRecord::Migration.rename_table @model.table_name, :newname
|
243
248
|
end
|
244
249
|
|
245
250
|
it "should rename fk indexes" do
|
246
|
-
index = ActiveRecord::Base.connection.indexes(:newname).find
|
251
|
+
index = ActiveRecord::Base.connection.indexes(:newname).find { |it| it.columns == ['user_id'] }
|
247
252
|
expect(index.name).to match(/^fk__newname_/)
|
248
253
|
end
|
249
254
|
|
250
255
|
end
|
251
256
|
|
252
|
-
context "when column is added", :
|
257
|
+
context "when column is added", sqlite3: :skip do
|
253
258
|
|
254
259
|
before(:each) do
|
255
260
|
@model = Comment
|
256
261
|
end
|
257
262
|
|
258
263
|
it "auto creates foreign key" do
|
259
|
-
add_column(:post_id, :
|
264
|
+
add_column(:post_id, :bigint) do
|
260
265
|
expect(@model).to reference(:posts, :id).on(:post_id)
|
261
266
|
end
|
262
267
|
end
|
263
268
|
|
264
269
|
it "respects explicit foreign key" do
|
265
|
-
add_column(:author_id, :
|
270
|
+
add_column(:author_id, :bigint, foreign_key: { references: :users }) do
|
266
271
|
expect(@model).to reference(:users, :id).on(:author_id)
|
267
272
|
end
|
268
273
|
end
|
269
274
|
|
270
275
|
it "doesn't create foreign key if column doesn't look like foreign key" do
|
271
|
-
add_column(:views_count, :
|
276
|
+
add_column(:views_count, :bigint) do
|
272
277
|
expect(@model).not_to reference.on(:views_count)
|
273
278
|
end
|
274
279
|
end
|
275
280
|
|
276
281
|
it "doesn't create foreign key if declined explicitly" do
|
277
|
-
add_column(:post_id, :
|
282
|
+
add_column(:post_id, :bigint, foreign_key: false) do
|
278
283
|
expect(@model).not_to reference.on(:post_id)
|
279
284
|
end
|
280
285
|
end
|
281
286
|
|
282
287
|
it "shouldn't create foreign key if declined explicitly by shorthand" do
|
283
|
-
add_column(:post_id, :
|
288
|
+
add_column(:post_id, :bigint, references: nil) do
|
284
289
|
expect(@model).not_to reference.on(:post_id)
|
285
290
|
end
|
286
291
|
end
|
287
292
|
|
288
293
|
it "creates auto index" do
|
289
|
-
add_column(:post_id, :
|
294
|
+
add_column(:post_id, :bigint) do
|
290
295
|
expect(@model).to have_index.on(:post_id)
|
291
296
|
end
|
292
297
|
end
|
293
298
|
|
294
299
|
it "does not create auto-index for non-foreign keys" do
|
295
|
-
add_column(:state, :
|
300
|
+
add_column(:state, :bigint) do
|
296
301
|
expect(@model).not_to have_index.on(:state)
|
297
302
|
end
|
298
303
|
end
|
299
304
|
|
300
305
|
# MySQL creates an index on foreign key and we can't override that
|
301
|
-
it "doesn't create auto-index if declined explicitly", :
|
302
|
-
add_column(:post_id, :
|
306
|
+
it "doesn't create auto-index if declined explicitly", mysql: :skip do
|
307
|
+
add_column(:post_id, :bigint, index: false) do
|
303
308
|
expect(@model).not_to have_index.on(:post_id)
|
304
309
|
end
|
305
310
|
end
|
306
311
|
|
307
312
|
protected
|
308
|
-
def add_column(column_name,
|
313
|
+
def add_column(column_name, type, **kwargs)
|
309
314
|
table = @model.table_name
|
310
|
-
ActiveRecord::Migration.add_column(table, column_name,
|
315
|
+
ActiveRecord::Migration.add_column(table, column_name, type, **kwargs)
|
311
316
|
@model.reset_column_information
|
312
317
|
yield if block_given?
|
313
318
|
ActiveRecord::Migration.remove_column(table, column_name)
|
@@ -321,13 +326,13 @@ describe ActiveRecord::Migration do
|
|
321
326
|
@model = Comment
|
322
327
|
end
|
323
328
|
|
324
|
-
context "with foreign keys", :
|
329
|
+
context "with foreign keys", sqlite3: :skip do
|
325
330
|
|
326
331
|
context "and initially references to users table" do
|
327
332
|
|
328
333
|
before(:each) do
|
329
334
|
create_table @model do |t|
|
330
|
-
t.
|
335
|
+
t.bigint :user_id
|
331
336
|
end
|
332
337
|
end
|
333
338
|
|
@@ -336,13 +341,13 @@ describe ActiveRecord::Migration do
|
|
336
341
|
end
|
337
342
|
|
338
343
|
it "should drop foreign key if requested to do so" do
|
339
|
-
change_column :user_id, :
|
344
|
+
change_column :user_id, :bigint, foreign_key: { references: nil }
|
340
345
|
expect(@model).not_to reference(:users)
|
341
346
|
end
|
342
347
|
|
343
|
-
it "should remove auto-created index if foreign key is removed", :
|
348
|
+
it "should remove auto-created index if foreign key is removed", mysql: :skip do
|
344
349
|
expect(@model).to have_index.on(:user_id) # sanity check that index was auto-created
|
345
|
-
change_column :user_id, :
|
350
|
+
change_column :user_id, :bigint, foreign_key: { references: nil }
|
346
351
|
expect(@model).not_to have_index.on(:user_id)
|
347
352
|
end
|
348
353
|
|
@@ -351,7 +356,7 @@ describe ActiveRecord::Migration do
|
|
351
356
|
context "if column defined without foreign key but with index" do
|
352
357
|
before(:each) do
|
353
358
|
create_table @model do |t|
|
354
|
-
t.
|
359
|
+
t.bigint :user_id, foreign_key: false, index: true
|
355
360
|
end
|
356
361
|
end
|
357
362
|
|
@@ -360,7 +365,7 @@ describe ActiveRecord::Migration do
|
|
360
365
|
end
|
361
366
|
|
362
367
|
it "adding foreign key should not fail due to attempt to auto-create existing index" do
|
363
|
-
expect { change_column :user_id, :
|
368
|
+
expect { change_column :user_id, :bigint, foreign_key: true }.to_not raise_error
|
364
369
|
end
|
365
370
|
end
|
366
371
|
end
|
@@ -369,7 +374,7 @@ describe ActiveRecord::Migration do
|
|
369
374
|
|
370
375
|
it "doesn't auto-add foreign keys" do
|
371
376
|
create_table @model do |t|
|
372
|
-
t.
|
377
|
+
t.bigint :user_id, foreign_key: false
|
373
378
|
t.string :other_column
|
374
379
|
end
|
375
380
|
with_fk_auto_create do
|
@@ -381,23 +386,22 @@ describe ActiveRecord::Migration do
|
|
381
386
|
end
|
382
387
|
|
383
388
|
protected
|
384
|
-
def change_column(column_name,
|
389
|
+
def change_column(column_name, type, **kwargs)
|
385
390
|
table = @model.table_name
|
386
|
-
ActiveRecord::Migration.change_column(table, column_name,
|
391
|
+
ActiveRecord::Migration.change_column(table, column_name, type, **kwargs)
|
387
392
|
@model.reset_column_information
|
388
393
|
end
|
389
394
|
|
390
395
|
end
|
391
396
|
|
392
397
|
def create_table(model, opts={}, &block)
|
393
|
-
ActiveRecord::Migration.create_table model.table_name, opts.merge(:
|
398
|
+
ActiveRecord::Migration.create_table model.table_name, **opts.merge(force: true, id: :bigint), &block
|
394
399
|
model.reset_column_information
|
395
400
|
end
|
396
401
|
|
397
402
|
def change_table(model, opts={}, &block)
|
398
|
-
ActiveRecord::Migration.change_table model.table_name, opts, &block
|
403
|
+
ActiveRecord::Migration.change_table model.table_name, **opts, &block
|
399
404
|
model.reset_column_information
|
400
405
|
end
|
401
406
|
|
402
407
|
end
|
403
|
-
|
data/spec/schema_spec.rb
CHANGED
@@ -10,19 +10,19 @@ describe ActiveRecord::Schema do
|
|
10
10
|
with_fk_config(auto_create: true, auto_index: true) do
|
11
11
|
ActiveRecord::Schema.define do
|
12
12
|
|
13
|
-
create_table :users, :
|
13
|
+
create_table :users, force: :cascade do
|
14
14
|
end
|
15
15
|
|
16
|
-
create_table :colors, :
|
16
|
+
create_table :colors, force: :cascade do
|
17
17
|
end
|
18
18
|
|
19
|
-
create_table :shoes, :
|
19
|
+
create_table :shoes, force: :cascade do
|
20
20
|
end
|
21
21
|
|
22
|
-
create_table :posts, :
|
23
|
-
t.
|
24
|
-
t.
|
25
|
-
t.
|
22
|
+
create_table :posts, force: true do |t|
|
23
|
+
t.bigint :user_id, references: :users, index: true
|
24
|
+
t.bigint :shoe_id, references: :shoes # should not have an index (except mysql)
|
25
|
+
t.bigint :color_id # should not have a foreign key nor index
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
|
3
|
-
SimpleCov.start "gem"
|
2
|
+
SimpleCov.start
|
4
3
|
|
5
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -37,7 +36,7 @@ def with_fk_config(opts={}, &block)
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def with_fk_auto_create(value = true, &block)
|
40
|
-
with_fk_config(:
|
39
|
+
with_fk_config(auto_create: value, &block)
|
41
40
|
end
|
42
41
|
|
43
42
|
def define_schema(&block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_auto_foreign_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: schema_plus_foreign_keys
|
@@ -16,70 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: schema_plus_indexes
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: its-it
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.2'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.2'
|
40
|
+
version: 1.0.0
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - "
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
61
|
+
version: '13.0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '13.0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,42 +86,14 @@ dependencies:
|
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '4.1'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: simplecov
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: simplecov-gem-profile
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
96
|
+
version: '4.1'
|
139
97
|
description: In an ActiveRecord migration, set the default to create a foreign key
|
140
98
|
and index for all columns that define relatoins.
|
141
99
|
email:
|
@@ -144,21 +102,22 @@ executables: []
|
|
144
102
|
extensions: []
|
145
103
|
extra_rdoc_files: []
|
146
104
|
files:
|
105
|
+
- ".github/workflows/prs.yml"
|
147
106
|
- ".gitignore"
|
148
|
-
- ".
|
107
|
+
- ".simplecov"
|
149
108
|
- Gemfile
|
150
109
|
- LICENSE.txt
|
151
110
|
- README.md
|
152
111
|
- Rakefile
|
153
112
|
- gemfiles/Gemfile.base
|
154
|
-
- gemfiles/activerecord-
|
155
|
-
- gemfiles/activerecord-
|
156
|
-
- gemfiles/activerecord-
|
157
|
-
- gemfiles/activerecord-
|
158
|
-
- gemfiles/activerecord-
|
159
|
-
- gemfiles/activerecord-
|
160
|
-
- gemfiles/activerecord-
|
161
|
-
- gemfiles/activerecord-
|
113
|
+
- gemfiles/activerecord-5.2/Gemfile.base
|
114
|
+
- gemfiles/activerecord-5.2/Gemfile.mysql2
|
115
|
+
- gemfiles/activerecord-5.2/Gemfile.postgresql
|
116
|
+
- gemfiles/activerecord-5.2/Gemfile.sqlite3
|
117
|
+
- gemfiles/activerecord-6.0/Gemfile.base
|
118
|
+
- gemfiles/activerecord-6.0/Gemfile.mysql2
|
119
|
+
- gemfiles/activerecord-6.0/Gemfile.postgresql
|
120
|
+
- gemfiles/activerecord-6.0/Gemfile.sqlite3
|
162
121
|
- lib/schema_auto_foreign_keys.rb
|
163
122
|
- lib/schema_auto_foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb
|
164
123
|
- lib/schema_auto_foreign_keys/middleware/migration.rb
|
@@ -176,7 +135,7 @@ homepage: https://github.com/SchemaPlus/schema_auto_foreign_keys
|
|
176
135
|
licenses:
|
177
136
|
- MIT
|
178
137
|
metadata: {}
|
179
|
-
post_install_message:
|
138
|
+
post_install_message:
|
180
139
|
rdoc_options: []
|
181
140
|
require_paths:
|
182
141
|
- lib
|
@@ -184,16 +143,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
143
|
requirements:
|
185
144
|
- - ">="
|
186
145
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
146
|
+
version: 2.5.0
|
188
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
148
|
requirements:
|
190
149
|
- - ">="
|
191
150
|
- !ruby/object:Gem::Version
|
192
151
|
version: '0'
|
193
152
|
requirements: []
|
194
|
-
|
195
|
-
|
196
|
-
signing_key:
|
153
|
+
rubygems_version: 3.0.8
|
154
|
+
signing_key:
|
197
155
|
specification_version: 4
|
198
156
|
summary: Automatically define foreign key constraints in ActiveRecord
|
199
157
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
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
|
-
sudo: false
|
7
|
-
rvm:
|
8
|
-
- 2.3.1
|
9
|
-
gemfile:
|
10
|
-
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
11
|
-
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
12
|
-
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
13
|
-
- gemfiles/activerecord-5.0/Gemfile.mysql2
|
14
|
-
- gemfiles/activerecord-5.0/Gemfile.postgresql
|
15
|
-
- gemfiles/activerecord-5.0/Gemfile.sqlite3
|
16
|
-
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
17
|
-
addons:
|
18
|
-
postgresql: '9.4'
|
19
|
-
before_script: bundle exec rake create_databases
|
20
|
-
after_script: bundle exec rake drop_databases
|
21
|
-
script: bundle exec rake travis
|