foreigner 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b450dcadd1e5c2ea9a317d290889057748b97d24
4
- data.tar.gz: 576ad25ce8af650e1bc7277eb533f68219341bc7
3
+ metadata.gz: 6267757603fa3cc7daf2d7c9fb0cd5c3c0b5de57
4
+ data.tar.gz: 59ba0f7366cbfbbc9c315c6a4f3141c7ccefd887
5
5
  SHA512:
6
- metadata.gz: e31834038d39f1bc66234f0d7893889802c5793624e74d2b0dd076aa1e2fb2d2fbfbe968f4a0a94defd71616b75e90331ee9ccc3a53cb7df77f8b9c4758575a9
7
- data.tar.gz: e1b7c552f65517cafa9ec2e2864dae07be605d4c6295f62964459f52b03ed34769fbe1820e4717cc42f2e46ba5969a68923d8bf60b578cccc6e19fd5a84e71d6
6
+ metadata.gz: 0692abaca90f8bf9afe7a1b034062741d1cb6288816f7491aac15e566392121338dab6814bd94adf3dabb0a1acd0262d1f62af938cc34030947be52ca26f3736
7
+ data.tar.gz: 17fd7783a3127006a0a2284f4c82ea4960fd81115c6a56c9fff3a2159952cf18b8aac1f7f8da1842e8f514308f87b38c6b0acc2e3e5b4dac7421e25fab3da8b6
data/README.md CHANGED
@@ -22,7 +22,7 @@ Foreigner adds two methods to migrations.
22
22
  * `add_foreign_key(from_table, to_table, options)`
23
23
  * `remove_foreign_key(from_table, options)`
24
24
 
25
- (Options are documented in `connection_adapters/abstract/schema_definitions.rb`):
25
+ (Options are documented in `connection_adapters/abstract/schema_statements.rb`):
26
26
 
27
27
  For example, given the following model:
28
28
  ```ruby
@@ -31,16 +31,26 @@ module Foreigner
31
31
  primary_key = options[:primary_key] || "id"
32
32
  dependency = dependency_sql(options[:dependent])
33
33
 
34
+ proper_name = proper_table_name(to_table)
35
+
34
36
  sql =
35
37
  "ADD CONSTRAINT #{quote_column_name(foreign_key_name)} " +
36
38
  "FOREIGN KEY (#{quote_column_name(column)}) " +
37
- "REFERENCES #{quote_table_name(ActiveRecord::Migrator.proper_table_name(to_table))}(#{primary_key})"
39
+ "REFERENCES #{quote_table_name(proper_name)}(#{primary_key})"
38
40
  sql << " #{dependency}" if dependency.present?
39
41
  sql << " #{options[:options]}" if options[:options]
40
42
 
41
43
  sql
42
44
  end
43
45
 
46
+ def proper_table_name(to_table)
47
+ if ActiveRecord::Migration.instance_methods(false).include? :proper_table_name
48
+ ActiveRecord::Migration.new.proper_table_name(to_table)
49
+ else
50
+ ActiveRecord::Migrator.proper_table_name(to_table)
51
+ end
52
+ end
53
+
44
54
  def remove_foreign_key(table, options)
45
55
  execute "ALTER TABLE #{quote_table_name(table)} #{remove_foreign_key_sql(table, options)}"
46
56
  end
@@ -77,4 +87,4 @@ module Foreigner
77
87
  end
78
88
  end
79
89
  end
80
- end
90
+ end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreigner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Higgins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.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
26
  version: 3.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: activerecord
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: 3.1.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: 3.1.0
41
27
  description: Adds helpers to migrations and dumps foreign keys to schema.rb
42
28
  email: developer@matthewhiggins.com
43
29
  executables: []
@@ -45,8 +31,9 @@ extensions: []
45
31
  extra_rdoc_files: []
46
32
  files:
47
33
  - MIT-LICENSE
48
- - Rakefile
49
34
  - README.md
35
+ - Rakefile
36
+ - lib/foreigner.rb
50
37
  - lib/foreigner/adapter.rb
51
38
  - lib/foreigner/connection_adapters/abstract/foreign_key_definition.rb
52
39
  - lib/foreigner/connection_adapters/abstract/schema_definitions.rb
@@ -62,7 +49,6 @@ files:
62
49
  - lib/foreigner/migration/command_recorder.rb
63
50
  - lib/foreigner/railtie.rb
64
51
  - lib/foreigner/schema_dumper.rb
65
- - lib/foreigner.rb
66
52
  - test/foreigner/adapter_test.rb
67
53
  - test/foreigner/connection_adapters/abstract/schema_statements_test.rb
68
54
  - test/foreigner/connection_adapters/abstract/table_definition_test.rb
@@ -82,17 +68,17 @@ require_paths:
82
68
  - lib
83
69
  required_ruby_version: !ruby/object:Gem::Requirement
84
70
  requirements:
85
- - - '>='
71
+ - - ">="
86
72
  - !ruby/object:Gem::Version
87
73
  version: 1.9.2
88
74
  required_rubygems_version: !ruby/object:Gem::Requirement
89
75
  requirements:
90
- - - '>='
76
+ - - ">="
91
77
  - !ruby/object:Gem::Version
92
78
  version: 1.3.5
93
79
  requirements: []
94
80
  rubyforge_project: foreigner
95
- rubygems_version: 2.0.3
81
+ rubygems_version: 2.2.0
96
82
  signing_key:
97
83
  specification_version: 4
98
84
  summary: Foreign Keys for Rails