ridgepole 0.5.1 → 0.5.2.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/README.md +6 -0
- data/bin/ridgepole +8 -1
- data/lib/ridgepole/client.rb +6 -1
- data/lib/ridgepole/diff.rb +1 -1
- data/lib/ridgepole/dumper.rb +6 -0
- data/lib/ridgepole/ext/mysql_awesome.rb +8 -0
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +1 -0
- data/spec/0_diff/dump_disable_unsigned_spec.rb +1 -1
- data/spec/bigint_pk/bigint_pkspec.rb +24 -0
- data/spec/cli/ridgepole_spec.rb +3 -0
- data/spec/collation/collation_spec.rb +132 -0
- data/spec/comment/comment_spec.rb +177 -175
- data/spec/dump/dump_class_method_spec.rb +14 -1
- data/spec/spec_helper.rb +15 -3
- data/spec/~pkdump/pkdump_spec.rb +2 -2
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e89391bd7d67f71ab9d326e42226fffaa1c23962
|
4
|
+
data.tar.gz: a1966c6828572057af20625308e2cd53c0d1875e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d6c97cf20903b6cbaaf4a2d1a15d6e4c49984011fd443a460cdff5b3a63af6cdf55ed2529674a62fbff468f678da4493bfe6994346ef31fe144396d08f34cf
|
7
|
+
data.tar.gz: 4dac5448a53e81c93847ae322e07940ec296627c8162afe62acdc406a4925992ca9d7e1e1414dec67c88494662c01704ca51d7d9af758eec305620c750ff2d02
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,9 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
23
23
|
* `>= 0.5.1`
|
24
24
|
* Add `--enable-migration-comments` option ([migration_comments](https://github.com/pinnymz/migration_comments) is required)
|
25
25
|
* Fix rails version `< 4.2.0`
|
26
|
+
* `>= 0.5.2`
|
27
|
+
* Add `--enable-mysql-awesome` option ([activerecord-mysql-awesome](https://github.com/kamipo/activerecord-mysql-awesome) is required)
|
28
|
+
* It is not possible to enable both `--enable-migration-comments` and `--enable-mysql-awesome`
|
26
29
|
|
27
30
|
## Installation
|
28
31
|
|
@@ -55,6 +58,7 @@ Usage: ridgepole [options]
|
|
55
58
|
-e, --export
|
56
59
|
--split
|
57
60
|
--split-with-dir
|
61
|
+
--without-table-options
|
58
62
|
-d, --diff DSL1 DSL2
|
59
63
|
--reverse
|
60
64
|
--with-apply
|
@@ -65,7 +69,9 @@ Usage: ridgepole [options]
|
|
65
69
|
--enable-mysql-pkdump
|
66
70
|
--enable-foreigner
|
67
71
|
--enable-migration-comments
|
72
|
+
--enable-mysql-awesome
|
68
73
|
--normalize-mysql-float
|
74
|
+
-r, --require LIBS
|
69
75
|
--log-file LOG_FILE
|
70
76
|
--verbose
|
71
77
|
--debug
|
data/bin/ridgepole
CHANGED
@@ -74,6 +74,7 @@ ARGV.options do |opt|
|
|
74
74
|
opt.on('-e', '--export') { set_mode[:export] }
|
75
75
|
opt.on('', '--split') {|v| split = true }
|
76
76
|
opt.on('', '--split-with-dir') {|v| split = :with_dir }
|
77
|
+
opt.on('', '--without-table-options') { options[:without_table_options] = true }
|
77
78
|
opt.on('-d', '--diff DSL1 DSL2') {|diff_arg1|
|
78
79
|
set_mode[:diff]
|
79
80
|
diff_arg2 = ARGV.first
|
@@ -94,8 +95,10 @@ ARGV.options do |opt|
|
|
94
95
|
opt.on('', '--enable-mysql-unsigned') { options[:enable_mysql_unsigned] = true }
|
95
96
|
opt.on('', '--enable-mysql-pkdump') { options[:enable_mysql_pkdump] = true }
|
96
97
|
opt.on('', '--enable-foreigner') { options[:enable_foreigner] = true }
|
97
|
-
opt.on('', '--enable-migration-comments') { options[:
|
98
|
+
opt.on('', '--enable-migration-comments') { options[:enable_migration_comments] = true }
|
99
|
+
opt.on('', '--enable-mysql-awesome') { options[:enable_mysql_awesome] = true }
|
98
100
|
opt.on('', '--normalize-mysql-float') { options[:normalize_mysql_float] = true }
|
101
|
+
opt.on('-r' , '--require LIBS', Array) {|v| v.each {|i| require i } }
|
99
102
|
opt.on('' , '--log-file LOG_FILE') {|v| options[:log_file] = v }
|
100
103
|
opt.on('' , '--verbose') { Ridgepole::Logger.verbose = true }
|
101
104
|
opt.on('' , '--debug') { options[:debug] = true }
|
@@ -118,6 +121,10 @@ ARGV.options do |opt|
|
|
118
121
|
end
|
119
122
|
|
120
123
|
begin
|
124
|
+
if options[:enable_migration_comments] and options[:enable_mysql_awesome]
|
125
|
+
raise "It is not possible to enable both `--enable-migration-comments` and `--enable-mysql-awesome`"
|
126
|
+
end
|
127
|
+
|
121
128
|
logger = Ridgepole::Logger.instance
|
122
129
|
logger.set_debug(options[:debug])
|
123
130
|
|
data/lib/ridgepole/client.rb
CHANGED
@@ -15,10 +15,15 @@ class Ridgepole::Client
|
|
15
15
|
require 'activerecord-mysql-pkdump'
|
16
16
|
end
|
17
17
|
|
18
|
-
if @options[:
|
18
|
+
if @options[:enable_migration_comments]
|
19
19
|
require 'migration_comments'
|
20
20
|
end
|
21
21
|
|
22
|
+
if @options[:enable_mysql_awesome]
|
23
|
+
require 'activerecord/mysql/awesome/base'
|
24
|
+
require 'ridgepole/ext/mysql_awesome.rb'
|
25
|
+
end
|
26
|
+
|
22
27
|
if @options[:enable_foreigner]
|
23
28
|
Ridgepole::ForeignKey.init
|
24
29
|
end
|
data/lib/ridgepole/diff.rb
CHANGED
data/lib/ridgepole/dumper.rb
CHANGED
@@ -34,6 +34,12 @@ class Ridgepole::Dumper
|
|
34
34
|
line !~ /\A#/ &&
|
35
35
|
line !~ /\AActiveRecord::Schema\.define/ &&
|
36
36
|
line !~ /\Aend/
|
37
|
+
}.map {|line|
|
38
|
+
if @options[:without_table_options] and line =~ /\A create_table /
|
39
|
+
line.gsub(/, options: "[^"]*"/, '')
|
40
|
+
else
|
41
|
+
line
|
42
|
+
end
|
37
43
|
}.join.strip_heredoc
|
38
44
|
|
39
45
|
definitions = []
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'active_record/connection_adapters/abstract/schema_definitions'
|
2
|
+
|
3
|
+
# XXX: https://github.com/waka/activerecord-mysql-unsigned/blob/v0.3.1/lib/activerecord-mysql-unsigned/active_record/v3/connection_adapters/abstract/schema_definitions.rb#L14
|
4
|
+
class ActiveRecord::ConnectionAdapters::TableDefinition
|
5
|
+
def primary_key(name, type = :primary_key, options = {})
|
6
|
+
column(name, type, options.merge(primary_key: true).reverse_merge(unsigned: true))
|
7
|
+
end
|
8
|
+
end
|
data/lib/ridgepole/version.rb
CHANGED
data/ridgepole.gemspec
CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'foreigner'
|
29
29
|
spec.add_development_dependency 'activerecord-mysql-pkdump', '>= 0.1.0'
|
30
30
|
spec.add_development_dependency 'migration_comments'
|
31
|
+
spec.add_development_dependency 'activerecord-mysql-awesome'
|
31
32
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#dump' do
|
2
2
|
context 'when there is a tables (disable unsigned)' do
|
3
3
|
before { restore_tables }
|
4
|
-
subject { client(enable_mysql_unsigned: false) }
|
4
|
+
subject { client(enable_mysql_unsigned: false, enable_mysql_awesome: false) }
|
5
5
|
|
6
6
|
it {
|
7
7
|
expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
|
@@ -0,0 +1,24 @@
|
|
1
|
+
if mysql_awesome_enabled?
|
2
|
+
describe 'Ridgepole::Client (with bigint pk)' do
|
3
|
+
let(:dsl) {
|
4
|
+
<<-RUBY
|
5
|
+
create_table "books", id: :primary_key, limit: 8, force: true do |t|
|
6
|
+
t.string "title", null: false
|
7
|
+
t.integer "author_id", null: false
|
8
|
+
t.datetime "created_at"
|
9
|
+
t.datetime "updated_at"
|
10
|
+
end
|
11
|
+
RUBY
|
12
|
+
}
|
13
|
+
|
14
|
+
context 'when dump with activerecord-mysql-pkdump' do
|
15
|
+
subject { client }
|
16
|
+
|
17
|
+
before { subject.diff(dsl).migrate }
|
18
|
+
|
19
|
+
it {
|
20
|
+
expect(show_create_table(:books)).to include '`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/cli/ridgepole_spec.rb
CHANGED
@@ -23,6 +23,7 @@ describe 'ridgepole' do
|
|
23
23
|
-e, --export
|
24
24
|
--split
|
25
25
|
--split-with-dir
|
26
|
+
--without-table-options
|
26
27
|
-d, --diff DSL1 DSL2
|
27
28
|
--reverse
|
28
29
|
--with-apply
|
@@ -33,7 +34,9 @@ describe 'ridgepole' do
|
|
33
34
|
--enable-mysql-pkdump
|
34
35
|
--enable-foreigner
|
35
36
|
--enable-migration-comments
|
37
|
+
--enable-mysql-awesome
|
36
38
|
--normalize-mysql-float
|
39
|
+
-r, --require LIBS
|
37
40
|
--log-file LOG_FILE
|
38
41
|
--verbose
|
39
42
|
--debug
|
@@ -0,0 +1,132 @@
|
|
1
|
+
if mysql_awesome_enabled?
|
2
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
3
|
+
context 'when change column (add collation)' do
|
4
|
+
let(:actual_dsl) {
|
5
|
+
<<-RUBY
|
6
|
+
create_table "employee_clubs", force: true do |t|
|
7
|
+
t.integer "emp_no", null: false
|
8
|
+
t.integer "club_id", null: false, unsigned: true
|
9
|
+
t.string "string", null: false
|
10
|
+
t.text "text", null: false
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:expected_dsl) {
|
16
|
+
<<-RUBY
|
17
|
+
create_table "employee_clubs", force: true do |t|
|
18
|
+
t.integer "emp_no", null: false
|
19
|
+
t.integer "club_id", null: false, unsigned: true
|
20
|
+
t.string "string", null: false, collation: "ascii_bin"
|
21
|
+
t.text "text", null: false, collation: "utf8mb4_bin"
|
22
|
+
end
|
23
|
+
RUBY
|
24
|
+
}
|
25
|
+
|
26
|
+
before { subject.diff(actual_dsl).migrate }
|
27
|
+
subject { client }
|
28
|
+
|
29
|
+
it {
|
30
|
+
delta = subject.diff(expected_dsl)
|
31
|
+
expect(delta.differ?).to be_truthy
|
32
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
33
|
+
delta.migrate
|
34
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when change column (delete collation)' do
|
39
|
+
let(:actual_dsl) {
|
40
|
+
<<-RUBY
|
41
|
+
create_table "employee_clubs", force: true do |t|
|
42
|
+
t.integer "emp_no", null: false
|
43
|
+
t.integer "club_id", null: false, unsigned: true
|
44
|
+
t.string "string", null: false, collation: "ascii_bin"
|
45
|
+
t.text "text", null: false, collation: "utf8mb4_bin"
|
46
|
+
end
|
47
|
+
RUBY
|
48
|
+
}
|
49
|
+
|
50
|
+
let(:expected_dsl) {
|
51
|
+
<<-RUBY
|
52
|
+
create_table "employee_clubs", force: true do |t|
|
53
|
+
t.integer "emp_no", null: false
|
54
|
+
t.integer "club_id", null: false, unsigned: true
|
55
|
+
t.string "string", null: false
|
56
|
+
t.text "text", null: false
|
57
|
+
end
|
58
|
+
RUBY
|
59
|
+
}
|
60
|
+
|
61
|
+
before { subject.diff(actual_dsl).migrate }
|
62
|
+
subject { client }
|
63
|
+
|
64
|
+
it {
|
65
|
+
delta = subject.diff(expected_dsl)
|
66
|
+
expect(delta.differ?).to be_truthy
|
67
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
68
|
+
delta.migrate
|
69
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when change column (change collation)' do
|
74
|
+
let(:actual_dsl) {
|
75
|
+
<<-RUBY
|
76
|
+
create_table "employee_clubs", force: true do |t|
|
77
|
+
t.integer "emp_no", null: false
|
78
|
+
t.integer "club_id", null: false, unsigned: true
|
79
|
+
t.string "string", null: false, collation: "ascii_bin"
|
80
|
+
t.text "text", null: false, collation: "utf8mb4_bin"
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
}
|
84
|
+
|
85
|
+
let(:expected_dsl) {
|
86
|
+
<<-RUBY
|
87
|
+
create_table "employee_clubs", force: true do |t|
|
88
|
+
t.integer "emp_no", null: false
|
89
|
+
t.integer "club_id", null: false, unsigned: true
|
90
|
+
t.string "string", null: false, collation: "utf8mb4_bin"
|
91
|
+
t.text "text", null: false, collation: "ascii_bin"
|
92
|
+
end
|
93
|
+
RUBY
|
94
|
+
}
|
95
|
+
|
96
|
+
before { subject.diff(actual_dsl).migrate }
|
97
|
+
subject { client }
|
98
|
+
|
99
|
+
it {
|
100
|
+
delta = subject.diff(expected_dsl)
|
101
|
+
expect(delta.differ?).to be_truthy
|
102
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
103
|
+
delta.migrate
|
104
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when change column (no change collation)' do
|
109
|
+
let(:actual_dsl) {
|
110
|
+
<<-RUBY
|
111
|
+
create_table "employee_clubs", force: true do |t|
|
112
|
+
t.integer "emp_no", null: false
|
113
|
+
t.integer "club_id", null: false, unsigned: true
|
114
|
+
t.string "string", null: false, collation: "ascii_bin"
|
115
|
+
t.text "text", null: false, collation: "utf8mb4_bin"
|
116
|
+
end
|
117
|
+
RUBY
|
118
|
+
}
|
119
|
+
|
120
|
+
before { subject.diff(actual_dsl).migrate }
|
121
|
+
subject { client }
|
122
|
+
|
123
|
+
it {
|
124
|
+
delta = subject.diff(actual_dsl)
|
125
|
+
expect(delta.differ?).to be_falsey
|
126
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
127
|
+
delta.migrate
|
128
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -1,177 +1,179 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
1
|
+
unless mysql_awesome_enabled?
|
2
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
3
|
+
context 'when change column (add comment)' do
|
4
|
+
let(:actual_dsl) {
|
5
|
+
<<-RUBY
|
6
|
+
create_table "employee_clubs", force: true do |t|
|
7
|
+
t.integer "emp_no", null: false
|
8
|
+
t.integer "club_id", null: false, unsigned: true
|
9
|
+
t.string "string", null: false
|
10
|
+
t.text "text", null: false
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:expected_dsl) {
|
16
|
+
<<-RUBY
|
17
|
+
create_table "employee_clubs", force: true do |t|
|
18
|
+
t.integer "emp_no", null: false, comment: "any comment"
|
19
|
+
t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
|
20
|
+
t.string "string", null: false, comment: "any comment3"
|
21
|
+
t.text "text", null: false, comment: "any comment4"
|
22
|
+
end
|
23
|
+
RUBY
|
24
|
+
}
|
25
|
+
|
26
|
+
before { subject.diff(actual_dsl).migrate }
|
27
|
+
subject { client(enable_migration_comments: true) }
|
28
|
+
|
29
|
+
it {
|
30
|
+
delta = subject.diff(expected_dsl)
|
31
|
+
expect(delta.differ?).to be_truthy
|
32
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
33
|
+
delta.migrate
|
34
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when change column (delete comment)' do
|
39
|
+
let(:actual_dsl) {
|
40
|
+
<<-RUBY
|
41
|
+
create_table "employee_clubs", force: true do |t|
|
42
|
+
t.integer "emp_no", null: false, comment: "any comment"
|
43
|
+
t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
|
44
|
+
t.string "string", null: false, comment: "any comment3"
|
45
|
+
t.text "text", null: false, comment: "any comment4"
|
46
|
+
end
|
47
|
+
RUBY
|
48
|
+
}
|
49
|
+
|
50
|
+
let(:expected_dsl) {
|
51
|
+
<<-RUBY
|
52
|
+
create_table "employee_clubs", force: true do |t|
|
53
|
+
t.integer "emp_no", null: false
|
54
|
+
t.integer "club_id", null: false, unsigned: true
|
55
|
+
t.string "string", null: false
|
56
|
+
t.text "text", null: false
|
57
|
+
end
|
58
|
+
RUBY
|
59
|
+
}
|
60
|
+
|
61
|
+
before { subject.diff(actual_dsl).migrate }
|
62
|
+
subject { client(enable_migration_comments: true) }
|
63
|
+
|
64
|
+
it {
|
65
|
+
delta = subject.diff(expected_dsl)
|
66
|
+
expect(delta.differ?).to be_truthy
|
67
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
68
|
+
delta.migrate
|
69
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when change column (change comment)' do
|
74
|
+
let(:actual_dsl) {
|
75
|
+
<<-RUBY
|
76
|
+
create_table "employee_clubs", force: true do |t|
|
77
|
+
t.integer "emp_no", null: false, comment: "any comment"
|
78
|
+
t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
|
79
|
+
t.string "string", null: false, comment: "any comment3"
|
80
|
+
t.text "text", null: false, comment: "any comment4"
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
}
|
84
|
+
|
85
|
+
let(:expected_dsl) {
|
86
|
+
<<-RUBY
|
87
|
+
create_table "employee_clubs", force: true do |t|
|
88
|
+
t.integer "emp_no", null: false, comment: "other comment"
|
89
|
+
t.integer "club_id", null: false, unsigned: true, comment: "other comment2"
|
90
|
+
t.string "string", null: false, comment: "other comment3"
|
91
|
+
t.text "text", null: false, comment: "other comment4"
|
92
|
+
end
|
93
|
+
RUBY
|
94
|
+
}
|
95
|
+
|
96
|
+
before { subject.diff(actual_dsl).migrate }
|
97
|
+
subject { client(enable_migration_comments: true) }
|
98
|
+
|
99
|
+
it {
|
100
|
+
delta = subject.diff(expected_dsl)
|
101
|
+
expect(delta.differ?).to be_truthy
|
102
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
103
|
+
delta.migrate
|
104
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when change column (no change comment)' do
|
109
|
+
let(:actual_dsl) {
|
110
|
+
<<-RUBY
|
111
|
+
create_table "employee_clubs", force: true do |t|
|
112
|
+
t.integer "emp_no", null: false, comment: "any comment"
|
113
|
+
t.integer "club_id", null: false, unsigned: true, comment: "any comment2"
|
114
|
+
t.string "string", null: false, comment: "any comment3"
|
115
|
+
t.text "text", null: false, comment: "any comment4"
|
116
|
+
end
|
117
|
+
RUBY
|
118
|
+
}
|
119
|
+
|
120
|
+
before { subject.diff(actual_dsl).migrate }
|
121
|
+
subject { client(enable_migration_comments: true) }
|
122
|
+
|
123
|
+
it {
|
124
|
+
delta = subject.diff(actual_dsl)
|
125
|
+
expect(delta.differ?).to be_falsey
|
126
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
127
|
+
delta.migrate
|
128
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'when create table (with comment)' do
|
133
|
+
let(:expected_dsl) {
|
134
|
+
<<-RUBY
|
135
|
+
create_table "employee_clubs", force: true, comment: "table comment" do |t|
|
136
|
+
t.integer "emp_no", null: false, comment: "other comment"
|
137
|
+
t.integer "club_id", null: false, unsigned: true, comment: "other comment2"
|
138
|
+
t.string "string", null: false, comment: "other comment3"
|
139
|
+
t.text "text", null: false, comment: "other comment4"
|
140
|
+
end
|
141
|
+
RUBY
|
142
|
+
}
|
143
|
+
|
144
|
+
subject { client(enable_migration_comments: true) }
|
145
|
+
|
146
|
+
it {
|
147
|
+
delta = subject.diff(expected_dsl)
|
148
|
+
expect(delta.differ?).to be_truthy
|
149
|
+
expect(subject.dump.strip).to be_empty
|
150
|
+
delta.migrate
|
151
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when drop table (with comment)' do
|
156
|
+
let(:actual_dsl) {
|
157
|
+
<<-RUBY
|
158
|
+
create_table "employee_clubs", force: true, comment: "table comment" do |t|
|
159
|
+
t.integer "emp_no", null: false, comment: "other comment"
|
160
|
+
t.integer "club_id", null: false, unsigned: true, comment: "other comment2"
|
161
|
+
t.string "string", null: false, comment: "other comment3"
|
162
|
+
t.text "text", null: false, comment: "other comment4"
|
163
|
+
end
|
164
|
+
RUBY
|
165
|
+
}
|
166
|
+
|
167
|
+
before { subject.diff(actual_dsl).migrate }
|
168
|
+
subject { client(enable_migration_comments: true) }
|
169
|
+
|
170
|
+
it {
|
171
|
+
delta = subject.diff('')
|
172
|
+
expect(delta.differ?).to be_truthy
|
173
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
174
|
+
delta.migrate
|
175
|
+
expect(subject.dump).to be_empty
|
176
|
+
}
|
177
|
+
end
|
176
178
|
end
|
177
179
|
end
|
@@ -3,8 +3,21 @@ describe 'Ridgepole::Client.dump' do
|
|
3
3
|
before { restore_tables }
|
4
4
|
subject { Ridgepole::Client }
|
5
5
|
|
6
|
+
let(:options) {
|
7
|
+
opts = {}
|
8
|
+
|
9
|
+
if mysql_awesome_enabled?
|
10
|
+
opts[:enable_mysql_awesome] = true
|
11
|
+
opts[:without_table_options] = true
|
12
|
+
else
|
13
|
+
opts[:enable_mysql_unsigned] = true
|
14
|
+
end
|
15
|
+
|
16
|
+
opts
|
17
|
+
}
|
18
|
+
|
6
19
|
it {
|
7
|
-
expect(subject.dump(conn_spec,
|
20
|
+
expect(subject.dump(conn_spec, options)).to eq <<-RUBY.strip_heredoc.strip
|
8
21
|
create_table "clubs", force: true do |t|
|
9
22
|
t.string "name", default: "", null: false
|
10
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -49,10 +49,18 @@ end
|
|
49
49
|
def client(options = {}, config = {})
|
50
50
|
config = conn_spec(config)
|
51
51
|
|
52
|
-
|
53
|
-
:enable_mysql_unsigned => true,
|
52
|
+
default_options = {
|
54
53
|
:debug => !!ENV['DEBUG'],
|
55
|
-
}
|
54
|
+
}
|
55
|
+
|
56
|
+
if mysql_awesome_enabled?
|
57
|
+
default_options[:enable_mysql_awesome] = true
|
58
|
+
default_options[:without_table_options] = true
|
59
|
+
else
|
60
|
+
default_options[:enable_mysql_unsigned] = true
|
61
|
+
end
|
62
|
+
|
63
|
+
options = default_options.merge(options)
|
56
64
|
|
57
65
|
Ridgepole::Client.new(config, options)
|
58
66
|
end
|
@@ -129,3 +137,7 @@ def run_cli(options = {})
|
|
129
137
|
Open3.capture2e(cmd)
|
130
138
|
end
|
131
139
|
end
|
140
|
+
|
141
|
+
def mysql_awesome_enabled?
|
142
|
+
ENV['ENABLE_MYSQL_AWESOME'] == '1'
|
143
|
+
end
|
data/spec/~pkdump/pkdump_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe 'Ridgepole::Client (with pkdump)' do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'when create with activerecord-mysql-pkdump' do
|
30
|
-
subject { client(
|
30
|
+
subject { client(enable_mysql_pkdump: true) }
|
31
31
|
|
32
32
|
it {
|
33
33
|
delta = subject.diff(dsl)
|
@@ -39,7 +39,7 @@ describe 'Ridgepole::Client (with pkdump)' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'update create with activerecord-mysql-pkdump' do
|
42
|
-
subject { client(
|
42
|
+
subject { client(enable_mysql_pkdump: true) }
|
43
43
|
|
44
44
|
before { subject.diff(dsl).migrate }
|
45
45
|
|
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.5.
|
4
|
+
version: 0.5.2.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: activerecord-mysql-awesome
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
description: Ridgepole is a tool to manage DB schema. It defines DB schema using Rails
|
154
168
|
DSL, and updates DB schema according to DSL.
|
155
169
|
email:
|
@@ -176,14 +190,17 @@ files:
|
|
176
190
|
- lib/ridgepole/dumper.rb
|
177
191
|
- lib/ridgepole/execute_expander.rb
|
178
192
|
- lib/ridgepole/ext/foreign_key.rb
|
193
|
+
- lib/ridgepole/ext/mysql_awesome.rb
|
179
194
|
- lib/ridgepole/logger.rb
|
180
195
|
- lib/ridgepole/migration_ext.rb
|
181
196
|
- lib/ridgepole/schema_dumper_ext.rb
|
182
197
|
- lib/ridgepole/version.rb
|
183
198
|
- ridgepole.gemspec
|
184
199
|
- spec/0_diff/dump_disable_unsigned_spec.rb
|
200
|
+
- spec/bigint_pk/bigint_pkspec.rb
|
185
201
|
- spec/cli/config_spec.rb
|
186
202
|
- spec/cli/ridgepole_spec.rb
|
203
|
+
- spec/collation/collation_spec.rb
|
187
204
|
- spec/comment/comment_spec.rb
|
188
205
|
- spec/diff/diff2_spec.rb
|
189
206
|
- spec/diff/diff_spec.rb
|
@@ -250,9 +267,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
250
267
|
version: '0'
|
251
268
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
252
269
|
requirements:
|
253
|
-
- - '
|
270
|
+
- - '>'
|
254
271
|
- !ruby/object:Gem::Version
|
255
|
-
version:
|
272
|
+
version: 1.3.1
|
256
273
|
requirements: []
|
257
274
|
rubyforge_project:
|
258
275
|
rubygems_version: 2.0.14
|
@@ -261,8 +278,10 @@ specification_version: 4
|
|
261
278
|
summary: Ridgepole is a tool to manage DB schema.
|
262
279
|
test_files:
|
263
280
|
- spec/0_diff/dump_disable_unsigned_spec.rb
|
281
|
+
- spec/bigint_pk/bigint_pkspec.rb
|
264
282
|
- spec/cli/config_spec.rb
|
265
283
|
- spec/cli/ridgepole_spec.rb
|
284
|
+
- spec/collation/collation_spec.rb
|
266
285
|
- spec/comment/comment_spec.rb
|
267
286
|
- spec/diff/diff2_spec.rb
|
268
287
|
- spec/diff/diff_spec.rb
|