ridgepole 0.5.3.beta4 → 0.6.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -50
  3. data/bin/ridgepole +8 -18
  4. data/lib/ridgepole/client.rb +10 -16
  5. data/lib/ridgepole/delta.rb +57 -19
  6. data/lib/ridgepole/diff.rb +45 -14
  7. data/lib/ridgepole/dsl_parser.rb +38 -8
  8. data/lib/ridgepole/execute_expander.rb +0 -29
  9. data/lib/ridgepole/ext/mysql_awesome.rb +1 -5
  10. data/lib/ridgepole/version.rb +1 -1
  11. data/lib/ridgepole.rb +10 -2
  12. data/ridgepole.gemspec +3 -8
  13. data/spec/bigint_pk/bigint_pkspec.rb +2 -2
  14. data/spec/cli/ridgepole_spec.rb +3 -5
  15. data/spec/collation/collation_spec.rb +35 -35
  16. data/spec/diff/diff2_spec.rb +18 -18
  17. data/spec/diff/diff_spec.rb +18 -18
  18. data/spec/dump/dump_class_method_spec.rb +18 -18
  19. data/spec/dump/dump_some_tables_spec.rb +12 -12
  20. data/spec/dump/dump_spec.rb +18 -18
  21. data/spec/dump/dump_without_table_options_spec.rb +6 -6
  22. data/spec/migrate/check_orphan_index_spec.rb +8 -8
  23. data/spec/migrate/migrate_add_column2_spec.rb +15 -15
  24. data/spec/migrate/migrate_add_column_spec.rb +40 -40
  25. data/spec/migrate/migrate_change_column2_spec.rb +5 -5
  26. data/spec/migrate/migrate_change_column3_spec.rb +26 -26
  27. data/spec/migrate/migrate_change_column_float_spec.rb +7 -7
  28. data/spec/migrate/migrate_change_column_spec.rb +42 -42
  29. data/spec/migrate/migrate_change_index2_spec.rb +13 -13
  30. data/spec/migrate/migrate_change_index3_spec.rb +26 -26
  31. data/spec/migrate/migrate_change_index4_spec.rb +28 -28
  32. data/spec/migrate/migrate_change_index_spec.rb +46 -46
  33. data/spec/migrate/migrate_change_table_option_spec.rb +2 -2
  34. data/spec/migrate/migrate_create_index_spec.rb +18 -18
  35. data/spec/migrate/migrate_create_table_spec.rb +18 -18
  36. data/spec/migrate/migrate_create_table_with_options_spec.rb +3 -3
  37. data/spec/migrate/migrate_drop_column_and_index_2_spec.rb +35 -35
  38. data/spec/migrate/migrate_drop_column_and_index_spec.rb +33 -33
  39. data/spec/migrate/migrate_drop_column_spec.rb +36 -36
  40. data/spec/migrate/migrate_drop_index_spec.rb +18 -18
  41. data/spec/migrate/migrate_drop_table_spec.rb +24 -24
  42. data/spec/migrate/migrate_duplicate_index_spec.rb +1 -1
  43. data/spec/migrate/migrate_duplicate_table_spec.rb +2 -2
  44. data/spec/migrate/migrate_empty_spec.rb +18 -18
  45. data/spec/migrate/migrate_execute_spec.rb +58 -49
  46. data/spec/migrate/migrate_merge_mode_spec.rb +38 -38
  47. data/spec/migrate/migrate_noop_spec.rb +40 -40
  48. data/spec/migrate/migrate_rename_column_spec.rb +37 -37
  49. data/spec/migrate/migrate_rename_table_spec.rb +39 -39
  50. data/spec/migrate/migrate_same_default_null_spec.rb +4 -4
  51. data/spec/migrate/migrate_same_spec.rb +18 -18
  52. data/spec/migrate/migrate_script_error_spec.rb +8 -8
  53. data/spec/migrate/migrate_skip_rename_column_spec.rb +36 -36
  54. data/spec/migrate/migrate_skip_rename_table_spec.rb +36 -36
  55. data/spec/migrate/migrate_with_ignore_tables_spec.rb +12 -12
  56. data/spec/migrate/migrate_with_pre_post_query_spec.rb +32 -32
  57. data/spec/migrate/migrate_with_tables_spec.rb +12 -12
  58. data/spec/migrate_0/migrate_change_fk_spec.rb +11 -11
  59. data/spec/migrate_0/migrate_create_fk_spec.rb +29 -30
  60. data/spec/migrate_0/migrate_drop_fk_spec.rb +22 -23
  61. data/spec/spec_helper.rb +24 -2
  62. metadata +10 -89
  63. data/lib/ridgepole/ext/foreign_key.rb +0 -121
  64. data/spec/0_diff/dump_disable_unsigned_spec.rb +0 -75
  65. data/spec/comment/comment_spec.rb +0 -179
  66. data/spec/migrate/migrate_same_default_unsigned_spec.rb +0 -63
  67. data/spec/~pkdump/pkdump_spec.rb +0 -67
@@ -1,75 +0,0 @@
1
- describe 'Ridgepole::Client#dump' do
2
- context 'when there is a tables (disable unsigned)' do
3
- before { restore_tables }
4
- subject { client(enable_mysql_unsigned: false, enable_mysql_awesome: false) }
5
-
6
- it {
7
- expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
8
- create_table "clubs", force: true do |t|
9
- t.string "name", default: "", null: false
10
- end
11
-
12
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
13
-
14
- create_table "departments", primary_key: "dept_no", force: true do |t|
15
- t.string "dept_name", limit: 40, null: false
16
- end
17
-
18
- add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
19
-
20
- create_table "dept_emp", id: false, force: true do |t|
21
- t.integer "emp_no", null: false
22
- t.string "dept_no", limit: 4, null: false
23
- t.date "from_date", null: false
24
- t.date "to_date", null: false
25
- end
26
-
27
- add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
28
- add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
29
-
30
- create_table "dept_manager", id: false, force: true do |t|
31
- t.string "dept_no", limit: 4, null: false
32
- t.integer "emp_no", null: false
33
- t.date "from_date", null: false
34
- t.date "to_date", null: false
35
- end
36
-
37
- add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
38
- add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
39
-
40
- create_table "employee_clubs", force: true do |t|
41
- t.integer "emp_no", null: false
42
- t.integer "club_id", null: false
43
- end
44
-
45
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
46
-
47
- create_table "employees", primary_key: "emp_no", force: true do |t|
48
- t.date "birth_date", null: false
49
- t.string "first_name", limit: 14, null: false
50
- t.string "last_name", limit: 16, null: false
51
- t.string "gender", limit: 1, null: false
52
- t.date "hire_date", null: false
53
- end
54
-
55
- create_table "salaries", id: false, force: true do |t|
56
- t.integer "emp_no", null: false
57
- t.integer "salary", null: false
58
- t.date "from_date", null: false
59
- t.date "to_date", null: false
60
- end
61
-
62
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
63
-
64
- create_table "titles", id: false, force: true do |t|
65
- t.integer "emp_no", null: false
66
- t.string "title", limit: 50, null: false
67
- t.date "from_date", null: false
68
- t.date "to_date"
69
- end
70
-
71
- add_index "titles", ["emp_no"], name: "emp_no", using: :btree
72
- RUBY
73
- }
74
- end
75
- end
@@ -1,179 +0,0 @@
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
178
- end
179
- end
@@ -1,63 +0,0 @@
1
- describe 'Ridgepole::Client#diff -> migrate' do
2
- context 'when database and definition are same (default unsigned / nothing -> unsigned:false)' do
3
- let(:actual_dsl) {
4
- <<-RUBY
5
- create_table "employee_clubs", force: true do |t|
6
- t.integer "emp_no", null: false, unsigned: true
7
- t.integer "club_id", null: false
8
- end
9
- RUBY
10
- }
11
-
12
- let(:expected_dsl) {
13
- <<-RUBY
14
- create_table "employee_clubs", force: true do |t|
15
- t.integer "emp_no", null: false, unsigned: true
16
- t.integer "club_id", unsigned: false,null: false
17
- end
18
- RUBY
19
- }
20
-
21
- before { subject.diff(actual_dsl).migrate }
22
- subject { client }
23
-
24
- it {
25
- delta = subject.diff(expected_dsl)
26
- expect(delta.differ?).to be_falsey
27
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
28
- delta.migrate
29
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub('unsigned: false,', '')
30
- }
31
- end
32
-
33
- context 'when database and definition are same (default null / unsigned:false -> nothing)' do
34
- let(:actual_dsl) {
35
- <<-RUBY
36
- create_table "employee_clubs", force: true do |t|
37
- t.integer "emp_no", null: false, unsigned: true
38
- t.integer "club_id", unsigned: false,null: false
39
- end
40
- RUBY
41
- }
42
-
43
- let(:expected_dsl) {
44
- <<-RUBY
45
- create_table "employee_clubs", force: true do |t|
46
- t.integer "emp_no", null: false, unsigned: true
47
- t.integer "club_id", null: false
48
- end
49
- RUBY
50
- }
51
-
52
- before { subject.diff(actual_dsl).migrate }
53
- subject { client }
54
-
55
- it {
56
- delta = subject.diff(expected_dsl)
57
- expect(delta.differ?).to be_falsey
58
- expect(subject.dump).to eq actual_dsl.strip_heredoc.strip.gsub('unsigned: false,', '')
59
- delta.migrate
60
- expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
61
- }
62
- end
63
- end
@@ -1,67 +0,0 @@
1
- unless mysql_awesome_enabled?
2
- describe 'Ridgepole::Client (with pkdump)' do
3
- let(:dsl) {
4
- <<-RUBY
5
- create_table "authors", id: "bigint(20) PRIMARY KEY auto_increment", force: true do |t|
6
- t.string "name", null: false
7
- t.datetime "created_at"
8
- t.datetime "updated_at"
9
- end
10
-
11
- create_table "books", id: "bigint(20) PRIMARY KEY auto_increment", force: true do |t|
12
- t.string "title", null: false
13
- t.integer "author_id", null: false
14
- t.datetime "created_at"
15
- t.datetime "updated_at"
16
- end
17
- RUBY
18
- }
19
-
20
- context 'when dump with activerecord-mysql-pkdump' do
21
- subject { client(enable_mysql_pkdump: true) }
22
-
23
- before { subject.diff(dsl).migrate }
24
-
25
- it {
26
- expect(subject.dump).to eq dsl.strip_heredoc.strip
27
- }
28
- end
29
-
30
- context 'when create with activerecord-mysql-pkdump' do
31
- subject { client(enable_mysql_pkdump: true) }
32
-
33
- it {
34
- delta = subject.diff(dsl)
35
- expect(delta.differ?).to be_truthy
36
- expect(subject.dump.delete_empty_lines).to eq ''
37
- delta.migrate
38
- expect(subject.dump.delete_empty_lines).to eq dsl.strip_heredoc.strip.delete_empty_lines
39
- }
40
- end
41
-
42
- context 'update create with activerecord-mysql-pkdump' do
43
- subject { client(enable_mysql_pkdump: true) }
44
-
45
- before { subject.diff(dsl).migrate }
46
-
47
- let(:dsl2) {
48
- <<-RUBY
49
- create_table "books", id: "bigint(20) PRIMARY KEY auto_increment", force: true do |t|
50
- t.string "title2", null: false
51
- t.integer "author_id", null: false
52
- t.datetime "created_at"
53
- t.datetime "updated_at"
54
- end
55
- RUBY
56
- }
57
-
58
- it {
59
- delta = subject.diff(dsl2)
60
- expect(delta.differ?).to be_truthy
61
- expect(subject.dump.delete_empty_lines).to eq dsl.strip_heredoc.strip.delete_empty_lines
62
- delta.migrate
63
- expect(subject.dump.delete_empty_lines).to eq dsl2.strip_heredoc.strip.delete_empty_lines
64
- }
65
- end
66
- end
67
- end