activerecord-referential_integrity 1.0.0 → 2.1.0

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: d6ac2cbc77863e65e24222f60379683214e8e914
4
- data.tar.gz: d6c9043d8d080abd16499431d0c3b7b2dbcfed14
3
+ metadata.gz: 08474bec273e1d3087ba4479837c3aae401adb64
4
+ data.tar.gz: 1cd937521eb16cdc78dba3fe785eb0ab8d641502
5
5
  SHA512:
6
- metadata.gz: 3d20175adab2ba64911e5613c4d185a3182ec0c5f5207efc1c7dacb4d1e7633f30bf9bb3eff55617efb11c9fe495ceb2f2de068fb5c7c86705dc89c05be46592
7
- data.tar.gz: aac8adca5abed2d1fda0dec2a73938e8a4f1fc5de7ffa159eb1b5b3e2ff3cacee0e908f4a6e8abdbc418041a2d60dabb219a63fa94bc7a0603a66913f0e8bd17
6
+ metadata.gz: 1d85e24eb16ef0d5e4cd8f59c9d43f0b014a71fdeaae647e4957415430633a9b7597f485fa3f3f283b6a62fd1b90906be4d58600353b82333f41db6605e528fe
7
+ data.tar.gz: e185e1ea66d4506de636a09d2a208f85f834529010079b8c4d1c546b193062790eae1621a26af0984ce2b96d370141bc9ea8ef586bf9a14b286f959cc03a7c80
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Referential Integrity for ActiveRecord
2
2
 
3
- Adds as reversible `add_foreign_key` migration to Rails. `add_foreign_key`
4
- creates a database level foreign key constraint, this ensures that records
3
+ Adds as reversible `add_referential_integrity` migration to Rails. `add_referential_integrity`
4
+ creates a database level foreign key constraint, this ensures that records
5
5
  cannot reference foreign keys in other tables that do not exist.
6
6
 
7
- See [PostgreSQL foreign key constraint documentation](http://www.postgresql.org/docs/9.3/static/ddl-constraints.html#DDL-CONSTRAINTS-FK)
7
+ See [PostgreSQL foreign key constraint documentation](http://www.postgresql.org/docs/9.3/static/ddl-constraints.html#DDL-CONSTRAINTS-FK)
8
8
  for more.
9
9
 
10
10
  ## Limitations
@@ -28,7 +28,7 @@ Or install it yourself as:
28
28
 
29
29
  ## Usage
30
30
 
31
- Inside your migrations, call `add_foreign_key`, passing in the table and a hash of column => table pairs.
31
+ Inside your migrations, call `add_referential_integrity`, passing in the table and a hash of column => table pairs.
32
32
 
33
33
  For example:
34
34
  ```ruby
@@ -39,8 +39,8 @@ class CreateUserSettings < ActiveRecord::Migration
39
39
  # or t.integer :user_id, null: false
40
40
  [...]
41
41
  end
42
-
43
- add_foreign_key :somethings, :user_id => :users
42
+
43
+ add_referential_integrity :user_settings, user_id: :users
44
44
  end
45
45
  end
46
46
  ```
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ActiveRecord::ReferentialIntegrity::VERSION
9
9
  spec.authors = ['Martin Tithonium', 'John Wulff']
10
10
  spec.email = ['marty@orcasnet.com', 'johnw@orcasnet.com']
11
- spec.summary = %q{Adds add_foreign_key to Rails migrations with relevant databases}
12
- spec.description = %q{Adds as reversible add_foreign_key migration to Rails. Currently supports only PostgreSQL}
11
+ spec.summary = %q{Adds add_referential_integrity to Rails migrations with relevant databases}
12
+ spec.description = %q{Adds as reversible add_referential_integrity migration to Rails. Currently supports only PostgreSQL}
13
13
  spec.homepage = 'https://github.com/orcasnet/activerecord-referential_integrity'
14
14
  spec.license = 'MIT'
15
15
 
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'activerecord', '~> 3.2.16'
21
+ spec.add_dependency 'activerecord', '> 3.2.16'
22
22
  spec.add_development_dependency 'bundler', '~> 1.5'
23
23
  spec.add_development_dependency 'rake'
24
24
  end
@@ -1,9 +1,9 @@
1
1
  class ActiveRecord::ConnectionAdapters::AbstractAdapter
2
- def add_foreign_key(table, keypairs)
3
- raise NotImplementedError, 'add_foreign_key is not implemented'
2
+ def add_referential_integrity(table, keypairs)
3
+ raise NotImplementedError, 'add_referential_integrity is not implemented'
4
4
  end
5
5
 
6
- def drop_foreign_key(table, keys)
7
- raise NotImplementedError, 'drop_foreign_key is not implemented'
6
+ def drop_referential_integrity(table, keys)
7
+ raise NotImplementedError, 'drop_referential_integrity is not implemented'
8
8
  end
9
9
  end
@@ -1,19 +1,13 @@
1
1
  class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter < ActiveRecord::ConnectionAdapters::AbstractAdapter
2
- def add_foreign_key(table, keypairs)
2
+ def add_referential_integrity(table, keypairs)
3
3
  keypairs.each_pair do |foreign_key, foreign_table|
4
- sql = "ALTER TABLE #{table} "
5
- sql << "ADD CONSTRAINT #{table}_fk_#{foreign_key} "
6
- sql << "FOREIGN KEY (#{foreign_key}) "
7
- sql << "REFERENCES #{foreign_table} (id)"
8
- execute sql
4
+ execute "ALTER TABLE #{table} ADD CONSTRAINT #{table}_fk_#{foreign_key} FOREIGN KEY (#{foreign_key}) REFERENCES #{foreign_table} (id)"
9
5
  end
10
6
  end
11
7
 
12
- def drop_foreign_key(table, keys)
8
+ def drop_referential_integrity(table, keys)
13
9
  keys.each do |foreign_key|
14
- sql = "ALTER TABLE #{table} "
15
- sql << "DROP CONSTRAINT IF EXISTS #{table}_fk_#{foreign_key} "
16
- execute sql
10
+ execute "ALTER TABLE #{table} DROP CONSTRAINT IF EXISTS #{table}_fk_#{foreign_key}"
17
11
  end
18
12
  end
19
13
  end
@@ -1,11 +1,11 @@
1
1
  class ActiveRecord::Migration::CommandRecorder
2
- def add_foreign_key(*args)
3
- record(:add_foreign_key, args)
2
+ def add_referential_integrity(*args)
3
+ record(:add_referential_integrity, args)
4
4
  end
5
5
 
6
6
  private
7
7
 
8
- def invert_add_foreign_key(args)
9
- [:drop_foreign_key, [args.first, args.last.keys]]
8
+ def invert_add_referential_integrity(args)
9
+ [:drop_referential_integrity, [args.first, args.last.keys]]
10
10
  end
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module ReferentialIntegrity
3
- VERSION = '1.0.0'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-referential_integrity
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Tithonium
@@ -9,52 +9,52 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-11 00:00:00.000000000 Z
12
+ date: 2014-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - '>'
19
19
  - !ruby/object:Gem::Version
20
20
  version: 3.2.16
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - '>'
26
26
  - !ruby/object:Gem::Version
27
27
  version: 3.2.16
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.5'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.5'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- description: Adds as reversible add_foreign_key migration to Rails. Currently supports
57
- only PostgreSQL
56
+ description: Adds as reversible add_referential_integrity migration to Rails. Currently
57
+ supports only PostgreSQL
58
58
  email:
59
59
  - marty@orcasnet.com
60
60
  - johnw@orcasnet.com
@@ -62,7 +62,7 @@ executables: []
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - ".gitignore"
65
+ - .gitignore
66
66
  - Gemfile
67
67
  - LICENSE.txt
68
68
  - README.md
@@ -83,18 +83,18 @@ require_paths:
83
83
  - lib
84
84
  required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ">="
86
+ - - '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ">="
91
+ - - '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.2.0.rc.1
96
+ rubygems_version: 2.0.3
97
97
  signing_key:
98
98
  specification_version: 4
99
- summary: Adds add_foreign_key to Rails migrations with relevant databases
99
+ summary: Adds add_referential_integrity to Rails migrations with relevant databases
100
100
  test_files: []