ridgepole 0.5.1 → 0.5.2.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: 4ded281de053ba8c3ee49dde9acf4f1f5dbd0a46
4
- data.tar.gz: b9dc9e5fd0ee3a92420793f4485ec11930da9cf6
3
+ metadata.gz: e89391bd7d67f71ab9d326e42226fffaa1c23962
4
+ data.tar.gz: a1966c6828572057af20625308e2cd53c0d1875e
5
5
  SHA512:
6
- metadata.gz: a678c7f6b5744d4b4b9dd7fa1ed0c780a10b8e6299610929ec2f51b8f4a05bd964fd4d50ebfc619b456119aa3b51e94e1ac93d513019a6acb7e946b7f606ca0c
7
- data.tar.gz: e600e2d2ce35962f73ac90f00c517f6528a0ccdde124e068e1dcea1588ae9705dcfe9f0b2e42f28f2e6148a4413150d6a54f558f2c1d415b57c73a56df1c04f7
6
+ metadata.gz: 33d6c97cf20903b6cbaaf4a2d1a15d6e4c49984011fd443a460cdff5b3a63af6cdf55ed2529674a62fbff468f678da4493bfe6994346ef31fe144396d08f34cf
7
+ data.tar.gz: 4dac5448a53e81c93847ae322e07940ec296627c8162afe62acdc406a4925992ca9d7e1e1414dec67c88494662c01704ca51d7d9af758eec305620c750ff2d02
data/.travis.yml CHANGED
@@ -4,3 +4,7 @@ rvm:
4
4
  script:
5
5
  - bundle install
6
6
  - bundle exec rake
7
+ env:
8
+ matrix:
9
+ - ENABLE_MYSQL_AWESOME=0
10
+ - ENABLE_MYSQL_AWESOME=1
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[:migration_comments] = true }
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
 
@@ -15,10 +15,15 @@ class Ridgepole::Client
15
15
  require 'activerecord-mysql-pkdump'
16
16
  end
17
17
 
18
- if @options[:migration_comments]
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
@@ -255,7 +255,7 @@ class Ridgepole::Diff
255
255
  end
256
256
 
257
257
  # XXX: MySQL only?
258
- if @options[:enable_mysql_unsigned]
258
+ if @options[:enable_mysql_unsigned] or @options[:enable_mysql_awesome]
259
259
  opts[:unsigned] = false unless opts.has_key?(:unsigned)
260
260
  end
261
261
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2.beta'
3
3
  end
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
@@ -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
- 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
- }
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, enable_mysql_unsigned: true)).to eq <<-RUBY.strip_heredoc.strip
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
- options = {
53
- :enable_mysql_unsigned => true,
52
+ default_options = {
54
53
  :debug => !!ENV['DEBUG'],
55
- }.merge(options)
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
@@ -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(enable_foreigner: true) }
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(enable_foreigner: true) }
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.1
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: 2014-12-24 00:00:00.000000000 Z
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: '0'
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