foreigner 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -74,9 +74,10 @@ Remove an unwanted foreign key:
|
|
74
74
|
t.remove_foreign_key :users
|
75
75
|
end
|
76
76
|
|
77
|
-
==
|
77
|
+
== Foreigner Add-ons
|
78
78
|
|
79
|
-
|
79
|
+
* {immigrant}[https://github.com/jenseng/immigrant] - generate a migration that includes all missing foreign keys.
|
80
|
+
* {sqlserver-foreigner}[https://github.com/cleblanc87/sqlserver-foreigner] - A plugin for SQL Server.
|
80
81
|
|
81
82
|
== License
|
82
83
|
|
@@ -15,7 +15,11 @@ module Foreigner
|
|
15
15
|
definition = td # This is my trick to get the definition
|
16
16
|
block.call(td)
|
17
17
|
end
|
18
|
-
definition.foreign_keys.each
|
18
|
+
definition.foreign_keys.each do |to_table, options_list|
|
19
|
+
options_list.each do |options|
|
20
|
+
add_foreign_key(table_name, to_table, options)
|
21
|
+
end
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def supports_foreign_keys?
|
@@ -5,9 +5,17 @@ class Foreigner::ConnectionAdapters::TableDefinitionsTest < ActiveSupport::TestC
|
|
5
5
|
include Foreigner::ConnectionAdapters::TableDefinition
|
6
6
|
end
|
7
7
|
|
8
|
-
test "foreign_key" do
|
8
|
+
test "foreign_key used once" do
|
9
9
|
definition = TestDefinition.new
|
10
10
|
definition.foreign_key :poops, and: :one;
|
11
|
-
assert_equal definition.foreign_keys[:poops]
|
11
|
+
assert_equal [{ and: :one }], definition.foreign_keys[:poops]
|
12
|
+
end
|
13
|
+
|
14
|
+
test "foreign_key used twice" do
|
15
|
+
definition = TestDefinition.new
|
16
|
+
definition.foreign_key :nodes, column: :from_id
|
17
|
+
definition.foreign_key :nodes, column: :to_id
|
18
|
+
assert_equal [{ column: :from_id }, { column: :to_id }],
|
19
|
+
definition.foreign_keys[:nodes]
|
12
20
|
end
|
13
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreigner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|