rails-bigint-pk 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Changelog +6 -0
- data/Readme.md +35 -9
- data/lib/bigint_pk.rb +2 -0
- data/lib/bigint_pk/version.rb +1 -1
- data/lib/generators/bigint_pk/templates/migration.rb +1 -1
- data/rails-bigint-pk.gemspec +20 -16
- data/spec/fixtures/Gemfile +1 -1
- data/spec/integration/generator_spec.rb +1 -1
- data/spec/monkey_patch/connection_adapters_spec.rb +11 -2
- data/spec/spec_helper.rb +0 -1
- metadata +52 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc794aae7fc04ee85d379ac5433c4b2f37fa8cb3
|
4
|
+
data.tar.gz: f9bf0242a1c54f6ff5b8c98831dce75d6ee51c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 203ac729e7904234a26259da6a85974237a5d59609dab04dc6e6fd6ede45c0b842dff3a35c053e79854826ccb3b3aef6db6695c298111cffb7d0517dde51b8e8
|
7
|
+
data.tar.gz: e5514062891c3099206de073d7a45b9d2bb2eeede579744bfc6108592b97f3894337d8493b18f94f3de301264aeb0197a60a00976b3dc7d931da89acc240e5c2
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-1.
|
1
|
+
ruby-2.1.1
|
data/Changelog
CHANGED
data/Readme.md
CHANGED
@@ -2,23 +2,49 @@
|
|
2
2
|
|
3
3
|
### Overview
|
4
4
|
|
5
|
-
rails-bigint-pk
|
6
|
-
in
|
5
|
+
rails-bigint-pk is a simple, transparent way to use 64bit primary keys
|
6
|
+
in MySQL and PostgreSQL.
|
7
7
|
|
8
8
|
### Requirements
|
9
9
|
|
10
|
-
rails-bigint-pk has been tested with rails
|
11
|
-
is the latest patch version for
|
10
|
+
rails-bigint-pk has been tested with rails 4.0.4, which at the time of writing
|
11
|
+
is the latest patch version for 4.0. If you use a higher patch version, it is
|
12
12
|
recommended to run the test suite against your version of rails and activerecord.
|
13
13
|
|
14
14
|
### Installation & Usage
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
following to your
|
20
|
-
|
16
|
+
#### Rails 4
|
17
|
+
|
18
|
+
rails-bigint-pk supports Rails 4. To install, you can either
|
19
|
+
download releases from Rubygems by adding the following to your
|
20
|
+
`Gemfile`:
|
21
|
+
|
22
|
+
`gem 'rails-bigint-pk', '~>1.0.0'`
|
23
|
+
|
21
24
|
... or you can install the newest code directly from git:
|
25
|
+
|
26
|
+
`gem 'rails-bigint-pk', github: 'caboteria/rails-bigint-pk'`
|
27
|
+
|
28
|
+
Then run the generator:
|
29
|
+
`rails generate bigint_pk:install`
|
30
|
+
|
31
|
+
This will create an initializer that enables 64 bit primary and foreign keys by
|
32
|
+
changing the default primary key type, and using `limit: 8` for foreign keys
|
33
|
+
created via `references`.
|
34
|
+
|
35
|
+
It will also create a migration to update all existing primary and foreign keys.
|
36
|
+
|
37
|
+
#### Rails 3
|
38
|
+
|
39
|
+
There is a `rails3` branch for support of 3.2.x versions of Rails. To
|
40
|
+
install, you can either download 0.0.x releases from Rubygems by
|
41
|
+
adding the following to your `Gemfile`:
|
42
|
+
|
43
|
+
`gem 'rails-bigint-pk', '~>0.0.1'`
|
44
|
+
|
45
|
+
... or you can install the newest rails3 branch code directly from
|
46
|
+
git:
|
47
|
+
|
22
48
|
`gem 'rails-bigint-pk', github: 'caboteria/rails-bigint-pk', branch: 'rails3'`
|
23
49
|
|
24
50
|
Then run the generator:
|
data/lib/bigint_pk.rb
CHANGED
@@ -63,6 +63,8 @@ module BigintPk
|
|
63
63
|
references_without_default_bigint_fk( *args, options )
|
64
64
|
end
|
65
65
|
alias_method_chain :references, :default_bigint_fk
|
66
|
+
alias_method :belongs_to_without_default_bigint_fk, :belongs_to
|
67
|
+
alias_method :belongs_to, :references_with_default_bigint_fk
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
data/lib/bigint_pk/version.rb
CHANGED
@@ -5,7 +5,7 @@ class ChangeKeysToBigint < ActiveRecord::Migration
|
|
5
5
|
def change
|
6
6
|
Rails.application.eager_load!
|
7
7
|
ActiveRecord::Base.subclasses.select do |type|
|
8
|
-
connection.table_exists? type.table_name
|
8
|
+
type.primary_key.present? and connection.table_exists? type.table_name
|
9
9
|
end.each do |type|
|
10
10
|
BigintPk.update_primary_key type.table_name, type.primary_key
|
11
11
|
|
data/rails-bigint-pk.gemspec
CHANGED
@@ -9,28 +9,32 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["github@hjdivad.com"]
|
10
10
|
s.homepage = "https://github.com/caboteria/rails-bigint-pk"
|
11
11
|
s.summary = %q{Easily use 64-bit primary keys in rails}
|
12
|
-
s.description =
|
13
|
-
|
14
|
-
|
12
|
+
s.description = <<-DESC
|
13
|
+
Rails-bigint-pk modifies Rails so that it uses
|
14
|
+
64-bit primary and foreign keys. It works with
|
15
|
+
MySQL and PostgreSQL and has versions for Rails
|
16
|
+
3 and 4.
|
17
|
+
DESC
|
18
|
+
s.licenses = ['MIT']
|
15
19
|
|
16
20
|
s.files = `git ls-files`.split("\n")
|
17
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
22
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
23
|
s.require_paths = ["lib"]
|
20
24
|
|
21
|
-
s.add_runtime_dependency "activerecord", '~>
|
22
|
-
s.add_runtime_dependency "railties", '~>
|
25
|
+
s.add_runtime_dependency "activerecord", '~> 4.0.0'
|
26
|
+
s.add_runtime_dependency "railties", '~> 4.0.0'
|
23
27
|
|
24
|
-
s.add_development_dependency "rspec"
|
25
|
-
s.add_development_dependency "travis-lint"
|
26
|
-
s.add_development_dependency "rails"
|
27
|
-
s.add_development_dependency "mysql2", '~> 0.3
|
28
|
-
s.add_development_dependency "mysql", '~> 2.8
|
28
|
+
s.add_development_dependency "rspec", '~> 2.14'
|
29
|
+
s.add_development_dependency "travis-lint", '~> 1.7'
|
30
|
+
s.add_development_dependency "rails", '~> 4.0'
|
31
|
+
s.add_development_dependency "mysql2", '~> 0.3'
|
32
|
+
s.add_development_dependency "mysql", '~> 2.8'
|
29
33
|
s.add_development_dependency "pg", '~> 0.11'
|
30
|
-
s.add_development_dependency "sqlite3", '~> 1.3
|
31
|
-
s.add_development_dependency "guard"
|
32
|
-
s.add_development_dependency "guard-rspec"
|
33
|
-
s.add_development_dependency "guard-bundler"
|
34
|
-
s.add_development_dependency "guard-ctags-bundler"
|
35
|
-
s.add_development_dependency "rb-fsevent"
|
34
|
+
s.add_development_dependency "sqlite3", '~> 1.3'
|
35
|
+
s.add_development_dependency "guard", '~>2.5'
|
36
|
+
s.add_development_dependency "guard-rspec", '~> 4.2'
|
37
|
+
s.add_development_dependency "guard-bundler", '~> 2.0'
|
38
|
+
s.add_development_dependency "guard-ctags-bundler", '~> 1.0'
|
39
|
+
s.add_development_dependency "rb-fsevent", '~> 0.9'
|
36
40
|
end
|
data/spec/fixtures/Gemfile
CHANGED
@@ -10,7 +10,7 @@ describe BigintPk::Generators::InstallGenerator, :integration do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'creates a bigint_pk initializer' do
|
13
|
-
expect(
|
13
|
+
expect(File.exists? "#{RailsDir}/config/initializers/bigint_pk.rb")
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'creates a bigint_pk migration' do
|
@@ -12,6 +12,8 @@ describe BigintPk do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
+
ActiveRecord::ConnectionHandling.send :remove_const, :VALID_CONN_PARAMS
|
16
|
+
load 'active_record/connection_adapters/postgresql/referential_integrity.rb'
|
15
17
|
load 'active_record/connection_adapters/postgresql_adapter.rb'
|
16
18
|
load 'active_record/connection_adapters/abstract_mysql_adapter.rb'
|
17
19
|
end
|
@@ -63,12 +65,19 @@ describe BigintPk do
|
|
63
65
|
context 'when a limit is not specified' do
|
64
66
|
let(:options){}
|
65
67
|
|
66
|
-
it 'defaults the limit to 8' do
|
68
|
+
it 'defaults the references limit to 8' do
|
67
69
|
abstract_table.should_receive(:references_without_default_bigint_fk).with(
|
68
70
|
'some_other_table', hash_including( limit: 8 )
|
69
71
|
)
|
70
72
|
abstract_table.references *args
|
71
73
|
end
|
74
|
+
|
75
|
+
it 'defaults the belongs_to limit to 8' do
|
76
|
+
abstract_table.should_receive(:references_without_default_bigint_fk).with(
|
77
|
+
'some_other_table', hash_including( limit: 8 )
|
78
|
+
)
|
79
|
+
abstract_table.belongs_to *args
|
80
|
+
end
|
72
81
|
end
|
73
82
|
|
74
83
|
context 'when reference is polymorphic' do
|
@@ -110,7 +119,7 @@ describe BigintPk do
|
|
110
119
|
|
111
120
|
describe ActiveRecord::ConnectionAdapters::Table do
|
112
121
|
let(:abstract_table_class){ ActiveRecord::ConnectionAdapters::TableDefinition }
|
113
|
-
let(:abstract_table){ abstract_table_class.new
|
122
|
+
let(:abstract_table){ abstract_table_class.new({}, "table", {}, {}) }
|
114
123
|
it_makes_references_default_to_64bit
|
115
124
|
end
|
116
125
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-bigint-pk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David J. Hamilton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,98 +16,98 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.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: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.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:
|
40
|
+
version: 4.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.14'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: travis-lint
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.7'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '1.7'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '4.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '4.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mysql2
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.3
|
89
|
+
version: '0.3'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.3
|
96
|
+
version: '0.3'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: mysql
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.8
|
103
|
+
version: '2.8'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.8
|
110
|
+
version: '2.8'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pg
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,85 +128,89 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.3
|
131
|
+
version: '1.3'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.3
|
138
|
+
version: '1.3'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: guard
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '2.5'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '2.5'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: guard-rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '4.2'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '4.2'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: guard-bundler
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - "
|
171
|
+
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
173
|
+
version: '2.0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - "
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
180
|
+
version: '2.0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: guard-ctags-bundler
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
187
|
+
version: '1.0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
194
|
+
version: '1.0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: rb-fsevent
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- - "
|
199
|
+
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
201
|
+
version: '0.9'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- - "
|
206
|
+
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
|
-
description:
|
208
|
+
version: '0.9'
|
209
|
+
description: |2
|
210
|
+
Rails-bigint-pk modifies Rails so that it uses
|
211
|
+
64-bit primary and foreign keys. It works with
|
212
|
+
MySQL and PostgreSQL and has versions for Rails
|
213
|
+
3 and 4.
|
210
214
|
email:
|
211
215
|
- github@hjdivad.com
|
212
216
|
executables: []
|
@@ -251,7 +255,8 @@ files:
|
|
251
255
|
- spec/support/rails.rb
|
252
256
|
- spec/support/rspec.rb
|
253
257
|
homepage: https://github.com/caboteria/rails-bigint-pk
|
254
|
-
licenses:
|
258
|
+
licenses:
|
259
|
+
- MIT
|
255
260
|
metadata: {}
|
256
261
|
post_install_message:
|
257
262
|
rdoc_options: []
|
@@ -268,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
273
|
- !ruby/object:Gem::Version
|
269
274
|
version: '0'
|
270
275
|
requirements: []
|
271
|
-
rubyforge_project:
|
276
|
+
rubyforge_project:
|
272
277
|
rubygems_version: 2.2.2
|
273
278
|
signing_key:
|
274
279
|
specification_version: 4
|