ridgepole 0.5.0 → 0.5.1.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0e5d99302d1d99724e9f053f8828e443e43830c
4
- data.tar.gz: 2d23f1457802a52374e3c78aeabf56ab9d09b45f
3
+ metadata.gz: d48638146f584f343ed700c0e4fec7858e01dc4a
4
+ data.tar.gz: 259755ac2ee554776cf3a61683b1d5bf4e7084db
5
5
  SHA512:
6
- metadata.gz: 4ed2764b3cdf2353fd7ce49036f40d2d667f9482a0d833c2eb824b68ecd6450552e1c55a83a8c74b4358514cd315cb8212cdc107e72f43902d9b8e8c2c9e8967
7
- data.tar.gz: be1c4d45dde55c8030e6a025e6fc6a55a7934e549bac99b56dc0d1613a279ff306ed26cf402e78024aca194a34516818f5211aed93a0e65aceb801eea6488edc
6
+ metadata.gz: a73c8a63182aa7aa14ffc301d59b7ed610ce6450b3f380f4fdec980f3b3c0d32ff9cc93a5a5c0d130b06d47027c6b349ed239fd9483a546c037835274b135797
7
+ data.tar.gz: f2f7aed9e476a65789f9421b51cb7861d89ee3b75c6e0284d5b9f17f2cdce1d1c7516689077fded3f275c3ad72a624c0ab2f22b20abf0376e52ca45ec4c96d8c
data/README.md CHANGED
@@ -20,6 +20,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
20
20
  * Fix `activerecord-mysql-unsigned` version: `~> 0.2.0`
21
21
  * `>= 0.5.0`
22
22
  * Fix `activerecord-mysql-unsigned` version: `~> 0.3.1`
23
+ * `>= 0.5.1`
24
+ * Add `--enable-migration-comments` option ([migration_comments](https://github.com/pinnymz/migration_comments) is required)
23
25
 
24
26
  ## Installation
25
27
 
@@ -61,6 +63,7 @@ Usage: ridgepole [options]
61
63
  --enable-mysql-unsigned
62
64
  --enable-mysql-pkdump
63
65
  --enable-foreigner
66
+ --enable-migration-comments
64
67
  --log-file LOG_FILE
65
68
  --verbose
66
69
  --debug
@@ -160,6 +163,18 @@ add_index "child", ["parent_id"], name: "par_ind", using: :btree
160
163
  add_foreign_key "child", "parent", name: "child_ibfk_1", dependent: :delete
161
164
  ```
162
165
 
166
+ ## Comment
167
+ You can use the table/column comment by passing `--enable-migration-comments` ([migration_comments](https://github.com/pinnymz/migration_comments) is required)
168
+
169
+ ```ruby
170
+ create_table "articles", force: true, comment: "table comment" do |t|
171
+ t.string "title", comment: "column comment"
172
+ t.text "text"
173
+ t.datetime "created_at"
174
+ t.datetime "updated_at"
175
+ end
176
+ ```
177
+
163
178
  ## bigint support
164
179
  Export of `bigint` PK is enabled by passing `--enable-mysql-pkdump` ([activerecord-mysql-pkdump](https://github.com/winebarrel/activerecord-mysql-pkdump) is required)
165
180
 
data/bin/ridgepole CHANGED
@@ -94,6 +94,7 @@ ARGV.options do |opt|
94
94
  opt.on('', '--enable-mysql-unsigned') { options[:enable_mysql_unsigned] = true }
95
95
  opt.on('', '--enable-mysql-pkdump') { options[:enable_mysql_pkdump] = true }
96
96
  opt.on('', '--enable-foreigner') { options[:enable_foreigner] = true }
97
+ opt.on('', '--enable-migration-comments') { options[:migration_comments] = true }
97
98
  opt.on('' , '--log-file LOG_FILE') {|v| options[:log_file] = v }
98
99
  opt.on('' , '--verbose') { Ridgepole::Logger.verbose = true }
99
100
  opt.on('' , '--debug') { options[:debug] = true }
@@ -15,6 +15,10 @@ class Ridgepole::Client
15
15
  require 'activerecord-mysql-pkdump'
16
16
  end
17
17
 
18
+ if @options[:migration_comments]
19
+ require 'migration_comments'
20
+ end
21
+
18
22
  if @options[:enable_foreigner]
19
23
  Ridgepole::ForeignKey.init
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1.beta'
3
3
  end
data/ridgepole.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'activerecord-mysql-unsigned', '~> 0.3.1'
28
28
  spec.add_development_dependency 'foreigner'
29
29
  spec.add_development_dependency 'activerecord-mysql-pkdump', '>= 0.1.0'
30
+ spec.add_development_dependency 'migration_comments'
30
31
  end
@@ -32,6 +32,7 @@ describe 'ridgepole' do
32
32
  --enable-mysql-unsigned
33
33
  --enable-mysql-pkdump
34
34
  --enable-foreigner
35
+ --enable-migration-comments
35
36
  --log-file LOG_FILE
36
37
  --verbose
37
38
  --debug
@@ -0,0 +1,177 @@
1
+ describe 'Ridgepole::Client#diff -> migrate' do
2
+ context 'when change column (add comment)' do
3
+ let(:actual_dsl) {
4
+ <<-RUBY
5
+ create_table "employee_clubs", force: true do |t|
6
+ t.integer "emp_no", null: false
7
+ t.integer "club_id", null: false, unsigned: true
8
+ t.string "string", null: false
9
+ t.text "text", null: false
10
+ end
11
+ RUBY
12
+ }
13
+
14
+ let(:expected_dsl) {
15
+ <<-RUBY
16
+ create_table "employee_clubs", force: true do |t|
17
+ t.integer "emp_no", null: false, comment: "any comment"
18
+ t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
19
+ t.string "string", null: false, comment: "any comment3"
20
+ t.text "text", null: false, comment: "any comment4"
21
+ end
22
+ RUBY
23
+ }
24
+
25
+ before { subject.diff(actual_dsl).migrate }
26
+ subject { client(migration_comments: true) }
27
+
28
+ it {
29
+ delta = subject.diff(expected_dsl)
30
+ expect(delta.differ?).to be_truthy
31
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
32
+ delta.migrate
33
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
34
+ }
35
+ end
36
+
37
+ context 'when change column (delete comment)' do
38
+ let(:actual_dsl) {
39
+ <<-RUBY
40
+ create_table "employee_clubs", force: true do |t|
41
+ t.integer "emp_no", null: false, comment: "any comment"
42
+ t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
43
+ t.string "string", null: false, comment: "any comment3"
44
+ t.text "text", null: false, comment: "any comment4"
45
+ end
46
+ RUBY
47
+ }
48
+
49
+ let(:expected_dsl) {
50
+ <<-RUBY
51
+ create_table "employee_clubs", force: true do |t|
52
+ t.integer "emp_no", null: false
53
+ t.integer "club_id", null: false, unsigned: true
54
+ t.string "string", null: false
55
+ t.text "text", null: false
56
+ end
57
+ RUBY
58
+ }
59
+
60
+ before { subject.diff(actual_dsl).migrate }
61
+ subject { client(migration_comments: true) }
62
+
63
+ it {
64
+ delta = subject.diff(expected_dsl)
65
+ expect(delta.differ?).to be_truthy
66
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
67
+ delta.migrate
68
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
69
+ }
70
+ end
71
+
72
+ context 'when change column (change comment)' do
73
+ let(:actual_dsl) {
74
+ <<-RUBY
75
+ create_table "employee_clubs", force: true do |t|
76
+ t.integer "emp_no", null: false, comment: "any comment"
77
+ t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
78
+ t.string "string", null: false, comment: "any comment3"
79
+ t.text "text", null: false, comment: "any comment4"
80
+ end
81
+ RUBY
82
+ }
83
+
84
+ let(:expected_dsl) {
85
+ <<-RUBY
86
+ create_table "employee_clubs", force: true do |t|
87
+ t.integer "emp_no", null: false, comment: "other comment"
88
+ t.integer "club_id", null: false, unsigned: true, comment: "other comment2"
89
+ t.string "string", null: false, comment: "other comment3"
90
+ t.text "text", null: false, comment: "other comment4"
91
+ end
92
+ RUBY
93
+ }
94
+
95
+ before { subject.diff(actual_dsl).migrate }
96
+ subject { client(migration_comments: true) }
97
+
98
+ it {
99
+ delta = subject.diff(expected_dsl)
100
+ expect(delta.differ?).to be_truthy
101
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
102
+ delta.migrate
103
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
104
+ }
105
+ end
106
+
107
+ context 'when change column (no change comment)' do
108
+ let(:actual_dsl) {
109
+ <<-RUBY
110
+ create_table "employee_clubs", force: true do |t|
111
+ t.integer "emp_no", null: false, comment: "any comment"
112
+ t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
113
+ t.string "string", null: false, comment: "any comment3"
114
+ t.text "text", null: false, comment: "any comment4"
115
+ end
116
+ RUBY
117
+ }
118
+
119
+ before { subject.diff(actual_dsl).migrate }
120
+ subject { client(migration_comments: true) }
121
+
122
+ it {
123
+ delta = subject.diff(actual_dsl)
124
+ expect(delta.differ?).to be_falsey
125
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
126
+ delta.migrate
127
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
128
+ }
129
+ end
130
+
131
+ context 'when create table (with comment)' do
132
+ let(:expected_dsl) {
133
+ <<-RUBY
134
+ create_table "employee_clubs", force: true, comment: "table comment" do |t|
135
+ t.integer "emp_no", null: false, comment: "other comment"
136
+ t.integer "club_id", null: false, unsigned: true, comment: "other comment2"
137
+ t.string "string", null: false, comment: "other comment3"
138
+ t.text "text", null: false, comment: "other comment4"
139
+ end
140
+ RUBY
141
+ }
142
+
143
+ subject { client(migration_comments: true) }
144
+
145
+ it {
146
+ delta = subject.diff(expected_dsl)
147
+ expect(delta.differ?).to be_truthy
148
+ expect(subject.dump.strip).to be_empty
149
+ delta.migrate
150
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
151
+ }
152
+ end
153
+
154
+ context 'when drop table (with comment)' do
155
+ let(:actual_dsl) {
156
+ <<-RUBY
157
+ create_table "employee_clubs", force: true, comment: "table comment" do |t|
158
+ t.integer "emp_no", null: false, comment: "other comment"
159
+ t.integer "club_id", null: false, unsigned: true, comment: "other comment2"
160
+ t.string "string", null: false, comment: "other comment3"
161
+ t.text "text", null: false, comment: "other comment4"
162
+ end
163
+ RUBY
164
+ }
165
+
166
+ before { subject.diff(actual_dsl).migrate }
167
+ subject { client(migration_comments: true) }
168
+
169
+ it {
170
+ delta = subject.diff('')
171
+ expect(delta.differ?).to be_truthy
172
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
173
+ delta.migrate
174
+ expect(subject.dump).to be_empty
175
+ }
176
+ end
177
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridgepole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.1.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: migration_comments
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Ridgepole is a tool to manage DB schema. It defines DB schema using Rails
140
154
  DSL, and updates DB schema according to DSL.
141
155
  email:
@@ -170,6 +184,7 @@ files:
170
184
  - spec/0_diff/dump_disable_unsigned_spec.rb
171
185
  - spec/cli/config_spec.rb
172
186
  - spec/cli/ridgepole_spec.rb
187
+ - spec/comment/comment_spec.rb
173
188
  - spec/diff/diff_spec.rb
174
189
  - spec/dump/dump_class_method_spec.rb
175
190
  - spec/dump/dump_some_tables_spec.rb
@@ -233,9 +248,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
248
  version: '0'
234
249
  required_rubygems_version: !ruby/object:Gem::Requirement
235
250
  requirements:
236
- - - '>='
251
+ - - '>'
237
252
  - !ruby/object:Gem::Version
238
- version: '0'
253
+ version: 1.3.1
239
254
  requirements: []
240
255
  rubyforge_project:
241
256
  rubygems_version: 2.0.14
@@ -246,6 +261,7 @@ test_files:
246
261
  - spec/0_diff/dump_disable_unsigned_spec.rb
247
262
  - spec/cli/config_spec.rb
248
263
  - spec/cli/ridgepole_spec.rb
264
+ - spec/comment/comment_spec.rb
249
265
  - spec/diff/diff_spec.rb
250
266
  - spec/dump/dump_class_method_spec.rb
251
267
  - spec/dump/dump_some_tables_spec.rb