ridgepole 0.8.12 → 0.8.13

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
  SHA256:
3
- metadata.gz: 91c51bf51596b61eff43704847bd41b9f8035ceafd1f1e05e1cd72fc6632e582
4
- data.tar.gz: 32aff893209c48b839286b7efe24d465e3dd808d3b8820f52a5fb4eb9ecbf606
3
+ metadata.gz: 4c68b630030e34fb6e399e053d7d5c43245487c81d0869f9783b05e1135b5e2e
4
+ data.tar.gz: b7061e1c9c0bdf8e7509ab3601e397031edd2d9397975b178bac12ddb669c413
5
5
  SHA512:
6
- metadata.gz: 92c24eca95293b83ab73871c9baaff349e8d28be8ddc5583746d3beecf0b6986eb58127361654fc0742c95b68f9ac2c060ca689af98a9ca6558b78c960b2a35b
7
- data.tar.gz: 6864c16bbd8723436219540b7a3ab0f5eccfb32ae5301ac827957b9671c8cf83d7a91ea13a9a364f3b94ef236d2b3334742adce0524f7cb22801d298757cb0cd
6
+ metadata.gz: 8bbfcabaad944ad5ed18c5b809e06243582c9f3977890e499c2b400af7f268206876174d0cd3b6184e67b33ef67d5bd6226b63c88c13d820c9ed4fab5f5bdbdc
7
+ data.tar.gz: 7ed62d44a593d40b8c3d8b91b6d0ea7c10ae99337789db4ffbdffc9bf43cfb6b2e2fc81959cca1e823a9adf40968717d264f965aa4edb4e591bed55cff3c7c9d
data/README.md CHANGED
@@ -127,6 +127,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
127
127
  * Support t.reference() foreign_key option ([pull#316](https://github.com/winebarrel/ridgepole/pull/316))
128
128
  * `>= 0.8.12`
129
129
  * Pluralize column specified by `references` ([pull#317](https://github.com/winebarrel/ridgepole/pull/317))
130
+ * `>= 0.8.13`
131
+ * Support `serial` and `bigserial` column types ([pull#321](https://github.com/winebarrel/ridgepole/pull/321))
130
132
  </details>
131
133
 
132
134
  ## Installation
@@ -23,7 +23,7 @@ module Ridgepole
23
23
  end
24
24
 
25
25
  def adapter
26
- ActiveRecord::Base.connection_config.fetch(:adapter).to_sym
26
+ ActiveRecord::Base.connection.adapter_name.downcase.to_sym
27
27
  rescue ActiveRecord::ConnectionNotEstablished
28
28
  nil
29
29
  end
@@ -22,57 +22,60 @@ module Ridgepole
22
22
 
23
23
  DEFAULT_PRIMARY_KEY_TYPE = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('5.1') ? :bigint : :integer
24
24
 
25
- TYPES = [
25
+ TYPES = {
26
26
  # https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L274
27
- :string,
28
- :text,
29
- :integer,
30
- :bigint,
31
- :float,
32
- :decimal,
33
- :datetime,
34
- :timestamp,
35
- :time,
36
- :date,
37
- :binary,
38
- :boolean,
27
+ string: {},
28
+ text: {},
29
+ integer: {},
30
+ bigint: {},
31
+ float: {},
32
+ decimal: {},
33
+ datetime: {},
34
+ timestamp: {},
35
+ time: {},
36
+ date: {},
37
+ binary: {},
38
+ boolean: {},
39
39
 
40
40
  # https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L79
41
- :daterange,
42
- :numrange,
43
- :tsrange,
44
- :tstzrange,
45
- :int4range,
46
- :int8range,
47
- :binary,
48
- :boolean,
49
- :bigint,
50
- :xml,
51
- :tsvector,
52
- :hstore,
53
- :inet,
54
- :cidr,
55
- :macaddr,
56
- :uuid,
57
- :json,
58
- :jsonb,
59
- :ltree,
60
- :citext,
61
- :point,
62
- :bit,
63
- :bit_varying,
64
- :money,
41
+ serial: { null: false },
42
+ bigserial: { null: false },
43
+ daterange: {},
44
+ numrange: {},
45
+ tsrange: {},
46
+ tstzrange: {},
47
+ int4range: {},
48
+ int8range: {},
49
+ # binary: {}, # dup key
50
+ # boolean: {}, # dup key
51
+ # bigint: {}, # dup key
52
+ xml: {},
53
+ tsvector: {},
54
+ hstore: {},
55
+ inet: {},
56
+ cidr: {},
57
+ macaddr: {},
58
+ uuid: {},
59
+ json: {},
60
+ jsonb: {},
61
+ ltree: {},
62
+ citext: {},
63
+ point: {},
64
+ bit: {},
65
+ bit_varying: {},
66
+ money: {},
65
67
 
66
68
  # https://github.com/rails/rails/blob/v5.1.1/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L184
67
- :virtual,
69
+ virtual: {},
68
70
 
69
71
  # https://github.com/rails/rails/blob/v5.0.4/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L53
70
- :json
71
- ].uniq
72
+ # json: {}, # dup key
73
+ }.freeze
72
74
 
73
- TYPES.each do |column_type|
75
+ TYPES.each do |column_type, default_options|
74
76
  define_method column_type do |*args|
75
77
  options = args.extract_options!
78
+ options = default_options.merge(options)
76
79
  column_names = args
77
80
  column_names.each { |name| column(name, column_type, options) }
78
81
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '0.8.12'
4
+ VERSION = '0.8.13'
5
5
  end
@@ -36,5 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'rspec', '>= 3.0.0'
37
37
  spec.add_development_dependency 'rspec-match_fuzzy', '>= 0.1.3'
38
38
  spec.add_development_dependency 'rspec-match_ruby', '>= 0.1.3'
39
- spec.add_development_dependency 'rubocop', '>= 0.57.1'
39
+ spec.add_development_dependency 'rubocop', '>= 1.7.0'
40
+ spec.add_development_dependency 'rubocop-rake', '>= 0.5.1'
41
+ spec.add_development_dependency 'rubocop-rspec', '>= 2.1.0'
40
42
  end
@@ -116,10 +116,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
116
116
  end
117
117
 
118
118
  create_table "titles", id: false, force: :cascade do |t|
119
- t.integer "emp_no", null: false
120
- t.string "title", limit: 50, null: false
121
- t.date "from_date", null: false
122
- t.date "to_date"
119
+ t.integer "emp_no", null: false
120
+ t.string "title", limit: 50, null: false
121
+ t.date "from_date", null: false
122
+ t.date "to_date"
123
+ t.serial "title_no", null: false
124
+ t.bigserial "title_bigno", null: false
123
125
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
124
126
  end
125
127
  ERB
@@ -149,6 +151,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
149
151
  t.column("age", :integer, **{:null=>false})
150
152
  t.column("updated_at", :date, **{})
151
153
  end
154
+
155
+ change_table("titles", bulk: true) do |t|
156
+ t.column("title_no", :serial, **{:null=>false})
157
+ t.column("title_bigno", :bigserial, **{:null=>false})
158
+ end
152
159
  RUBY
153
160
  delta.migrate
154
161
  expect(subject.dump).to match_ruby expected_dsl
@@ -157,6 +157,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
157
157
  create_table "clubs", force: :cascade do |t|
158
158
  t.string "name", default: "", null: false
159
159
  t.text "desc"
160
+ t.serial "club_no"
161
+ t.bigserial "club_bigno"
160
162
  end
161
163
  ERB
162
164
  end
@@ -166,6 +168,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
166
168
  create_table "clubs", force: :cascade do |t|
167
169
  t.string "name", default: "", null: false
168
170
  t.text "desc"
171
+ t.serial "club_no"
172
+ t.bigserial "club_bigno"
169
173
  end
170
174
  ERB
171
175
  end
@@ -54,10 +54,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
54
54
  end
55
55
 
56
56
  create_table "titles", id: false, force: :cascade do |t|
57
- t.integer "emp_no", null: false
58
- t.string "title", limit: 50, null: false
59
- t.date "from_date", null: false
60
- t.date "to_date"
57
+ t.integer "emp_no", null: false
58
+ t.string "title", limit: 50, null: false
59
+ t.date "from_date", null: false
60
+ t.date "to_date"
61
+ t.serial "title_no", null: false
62
+ t.bigserial "title_bigno", null: false
61
63
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
62
64
  end
63
65
  ERB
@@ -148,6 +150,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
148
150
  t.remove("last_name")
149
151
  t.remove("hire_date")
150
152
  end
153
+
154
+ change_table("titles", bulk: true) do |t|
155
+ t.remove("title_no")
156
+ t.remove("title_bigno")
157
+ end
151
158
  RUBY
152
159
  delta.migrate
153
160
  expect(subject.dump).to match_ruby expected_dsl
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridgepole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.12
4
+ version: 0.8.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -218,14 +218,42 @@ dependencies:
218
218
  requirements:
219
219
  - - ">="
220
220
  - !ruby/object:Gem::Version
221
- version: 0.57.1
221
+ version: 1.7.0
222
222
  type: :development
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - ">="
227
227
  - !ruby/object:Gem::Version
228
- version: 0.57.1
228
+ version: 1.7.0
229
+ - !ruby/object:Gem::Dependency
230
+ name: rubocop-rake
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: 0.5.1
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: 0.5.1
243
+ - !ruby/object:Gem::Dependency
244
+ name: rubocop-rspec
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: 2.1.0
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: 2.1.0
229
257
  description: Ridgepole is a tool to manage DB schema. It defines DB schema using Rails
230
258
  DSL, and updates DB schema according to DSL.
231
259
  email: