schema_plus_foreign_keys 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +5 -3
- data/gemfiles/activerecord-4.2.0/Gemfile.mysql2 +2 -2
- data/gemfiles/activerecord-4.2.1/Gemfile.mysql2 +2 -2
- data/gemfiles/activerecord-4.2.6/Gemfile.base +3 -0
- data/gemfiles/activerecord-4.2.6/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-4.2.6/Gemfile.postgresql +10 -0
- data/gemfiles/activerecord-4.2.6/Gemfile.sqlite3 +10 -0
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/table_definition.rb +6 -2
- data/lib/schema_plus/foreign_keys/middleware/sql.rb +5 -4
- data/lib/schema_plus/foreign_keys/version.rb +1 -1
- data/schema_dev.yml +2 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 161f26b7a83ca42ce9fa30a6132447bbf1ca000e
|
4
|
+
data.tar.gz: 1393641fbdd4843d42558e12cf97d4792a9b3d18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0d962d24372f0fa68a9dd6775cb930d929a3dea94a438fc689a52628b1e0d5c24eefe1aefab160137d0355ac230cf15742e27cbce8186658a96e352ad59d35
|
7
|
+
data.tar.gz: 2db8b15e9be4c76bdef4b356882d00abce638585fc613c258ab8d77706ddf9d41dfdf4b455b23b5e738607687e25f13498e44a606a215a807d5a9bf3abd593d6
|
data/.travis.yml
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
---
|
6
6
|
sudo: false
|
7
7
|
rvm:
|
8
|
-
- 2.1.
|
8
|
+
- 2.1.8
|
9
9
|
gemfile:
|
10
10
|
- gemfiles/activerecord-4.2.0/Gemfile.mysql2
|
11
11
|
- gemfiles/activerecord-4.2.0/Gemfile.postgresql
|
@@ -13,6 +13,9 @@ gemfile:
|
|
13
13
|
- gemfiles/activerecord-4.2.1/Gemfile.mysql2
|
14
14
|
- gemfiles/activerecord-4.2.1/Gemfile.postgresql
|
15
15
|
- gemfiles/activerecord-4.2.1/Gemfile.sqlite3
|
16
|
+
- gemfiles/activerecord-4.2.6/Gemfile.mysql2
|
17
|
+
- gemfiles/activerecord-4.2.6/Gemfile.postgresql
|
18
|
+
- gemfiles/activerecord-4.2.6/Gemfile.sqlite3
|
16
19
|
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
17
20
|
addons:
|
18
21
|
postgresql: '9.4'
|
data/README.md
CHANGED
@@ -102,7 +102,7 @@ constraint, they normally default to whatever the DBMS's default behavior is.
|
|
102
102
|
But you can also configure a global default (e.g. in a Rails initializer):
|
103
103
|
|
104
104
|
```ruby
|
105
|
-
SchemaPlus::
|
105
|
+
SchemaPlus::ForeignKeys.setup do |config|
|
106
106
|
config.on_update = :cascade # default is nil, meaning use default dbms behavior
|
107
107
|
config.on_delete = :nullify # default is nil, meaning use default dbms behavior
|
108
108
|
end
|
@@ -142,13 +142,15 @@ SchemaPlus::ForeignKeys is tested on:
|
|
142
142
|
|
143
143
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
144
144
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
145
|
-
* ruby **2.1.
|
146
|
-
* ruby **2.1.
|
145
|
+
* ruby **2.1.8** with activerecord **4.2.0**, using **mysql2**, **sqlite3** or **postgresql**
|
146
|
+
* ruby **2.1.8** with activerecord **4.2.1**, using **mysql2**, **sqlite3** or **postgresql**
|
147
|
+
* ruby **2.1.8** with activerecord **4.2.6**, using **mysql2**, **sqlite3** or **postgresql**
|
147
148
|
|
148
149
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
149
150
|
|
150
151
|
## History
|
151
152
|
|
153
|
+
* 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)
|
152
154
|
* 0.1.2 - Handle very long names
|
153
155
|
* 0.1.1 - Cleanup; use (new) core Migration::RenameTable stack rather than monkey patching.
|
154
156
|
* 0.1.0 - Initial release, brought over from schema_plus 1.x via 2.0.0.pre*
|
@@ -67,7 +67,7 @@ module SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters
|
|
67
67
|
|
68
68
|
attr_accessor :schema_plus_foreign_keys_config #:nodoc:
|
69
69
|
|
70
|
-
if
|
70
|
+
if Gem::Requirement.new('= 4.2.0').satisfied_by?(::ActiveRecord.version)
|
71
71
|
def foreign_keys
|
72
72
|
@foreign_keys ||= []
|
73
73
|
end
|
@@ -75,10 +75,14 @@ module SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters
|
|
75
75
|
def foreign_keys_for_table(*)
|
76
76
|
foreign_keys
|
77
77
|
end
|
78
|
-
|
78
|
+
elsif Gem::Requirement.new('< 4.2.6').satisfied_by?(::ActiveRecord.version)
|
79
79
|
def foreign_keys_for_table(table)
|
80
80
|
foreign_keys[table] ||= []
|
81
81
|
end
|
82
|
+
else
|
83
|
+
def foreign_keys_for_table(*)
|
84
|
+
foreign_keys
|
85
|
+
end
|
82
86
|
end
|
83
87
|
|
84
88
|
def foreign_key(*args) # (column_names, to_table, primary_key=nil, options=nil)
|
@@ -3,14 +3,15 @@ module SchemaPlus::ForeignKeys
|
|
3
3
|
module Sql
|
4
4
|
module Table
|
5
5
|
def after(env)
|
6
|
-
foreign_keys =
|
7
|
-
|
8
|
-
else
|
6
|
+
foreign_keys = if env.table_definition.foreign_keys.is_a? Array
|
7
|
+
env.table_definition.foreign_keys
|
8
|
+
else
|
9
|
+
env.table_definition.foreign_keys.values.tap { |v| v.flatten! }
|
9
10
|
end
|
10
11
|
|
11
12
|
# create foreign key constraints inline in table definition
|
12
13
|
env.sql.body = ([env.sql.body] + foreign_keys.map(&:to_sql)).join(', ')
|
13
|
-
|
14
|
+
|
14
15
|
# prevents AR >= 4.2.1 from emitting add_foreign_key after the table
|
15
16
|
env.table_definition.foreign_keys.clear
|
16
17
|
end
|
data/schema_dev.yml
CHANGED
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: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -160,6 +160,10 @@ files:
|
|
160
160
|
- gemfiles/activerecord-4.2.1/Gemfile.mysql2
|
161
161
|
- gemfiles/activerecord-4.2.1/Gemfile.postgresql
|
162
162
|
- gemfiles/activerecord-4.2.1/Gemfile.sqlite3
|
163
|
+
- gemfiles/activerecord-4.2.6/Gemfile.base
|
164
|
+
- gemfiles/activerecord-4.2.6/Gemfile.mysql2
|
165
|
+
- gemfiles/activerecord-4.2.6/Gemfile.postgresql
|
166
|
+
- gemfiles/activerecord-4.2.6/Gemfile.sqlite3
|
163
167
|
- lib/schema_plus/foreign_keys.rb
|
164
168
|
- lib/schema_plus/foreign_keys/active_record/base.rb
|
165
169
|
- lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb
|