ridgepole 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +4 -0
  3. data/CHANGELOG.md +238 -0
  4. data/README.md +12 -142
  5. data/bin/ridgepole +1 -1
  6. data/docker-compose.yml +26 -18
  7. data/gemfiles/activerecord_7.0.gemfile +7 -0
  8. data/lib/ridgepole/delta.rb +1 -1
  9. data/lib/ridgepole/diff.rb +4 -1
  10. data/lib/ridgepole/execute_expander.rb +5 -2
  11. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +1 -0
  12. data/lib/ridgepole/version.rb +1 -1
  13. data/ridgepole.gemspec +8 -5
  14. metadata +10 -284
  15. data/.github/workflows/test.yml +0 -70
  16. data/.gitignore +0 -25
  17. data/spec/cli_helper.rb +0 -65
  18. data/spec/dsl_parser/context_spec.rb +0 -16
  19. data/spec/erb_helper.rb +0 -26
  20. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  21. data/spec/hide_pending_formatter.rb +0 -9
  22. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  23. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  24. data/spec/mysql/cli/config_spec.rb +0 -210
  25. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  26. data/spec/mysql/collation/collation_spec.rb +0 -153
  27. data/spec/mysql/comment/comment_spec.rb +0 -179
  28. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  29. data/spec/mysql/diff/diff2_spec.rb +0 -189
  30. data/spec/mysql/diff/diff_spec.rb +0 -168
  31. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  32. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  33. data/spec/mysql/dump/dump_spec.rb +0 -74
  34. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  35. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  36. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  37. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  38. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  39. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  40. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  41. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  42. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  43. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  44. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  45. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  46. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -231
  47. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  48. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  49. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  50. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  51. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  52. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  53. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
  54. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  55. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  56. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  57. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  58. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  59. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  60. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  61. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  62. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  63. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  64. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  65. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  66. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  67. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  68. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  69. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  70. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  71. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  72. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  73. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  74. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  75. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  76. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  77. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  78. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  79. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  80. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  81. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  82. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  83. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  84. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  85. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  86. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  87. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  88. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  89. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  90. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  91. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  92. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  93. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  94. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  95. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  96. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  97. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  98. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  99. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  100. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  101. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  102. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  103. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  104. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  105. data/spec/mysql/ridgepole_test_database.sql +0 -2
  106. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  107. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  108. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  109. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  110. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  111. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  112. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  113. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  114. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  115. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  116. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  117. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  118. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  119. data/spec/postgresql/diff/diff_spec.rb +0 -216
  120. data/spec/postgresql/dump/dump_spec.rb +0 -69
  121. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  122. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  123. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  124. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  125. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  126. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  127. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  128. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  129. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  130. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  131. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  132. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  133. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  134. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  135. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  136. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  137. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  138. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  139. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  140. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  141. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  142. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  143. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  144. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  145. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  146. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  147. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  148. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  149. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  150. data/spec/processing_for_ci.rb +0 -13
  151. data/spec/spec_condition.rb +0 -58
  152. data/spec/spec_const.rb +0 -20
  153. data/spec/spec_helper.rb +0 -173
@@ -1,158 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change column' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "clubs", force: :cascade do |t|
8
- t.string "name", default: "", null: false
9
- t.index ["name"], name: "idx_name", unique: true
10
- end
11
-
12
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
13
- t.string "dept_name", limit: 40, null: false
14
- t.index ["dept_name"], name: "dept_name", unique: true
15
- end
16
-
17
- create_table "dept_emp", id: false, force: :cascade do |t|
18
- t.integer "emp_no", null: false
19
- t.string "dept_no", null: false
20
- t.date "from_date", null: false
21
- t.date "to_date", null: false
22
- t.index ["dept_no"], name: "dept_no"
23
- t.index ["emp_no"], name: "emp_no"
24
- end
25
-
26
- create_table "dept_manager", id: false, force: :cascade do |t|
27
- t.string "dept_no", null: false
28
- t.integer "emp_no", null: false
29
- t.date "from_date", null: false
30
- t.date "to_date", null: false
31
- t.index ["dept_no"], name: "dept_no"
32
- t.index ["emp_no"], name: "emp_no"
33
- end
34
-
35
- create_table "employee_clubs", force: :cascade do |t|
36
- t.integer "emp_no", null: false
37
- t.integer "club_id", null: false
38
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
39
- end
40
-
41
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
42
- t.date "birth_date", null: false
43
- t.string "first_name", limit: 14, null: false
44
- t.string "last_name", limit: 16, null: false
45
- t.string "gender", limit: 1, null: false
46
- t.date "hire_date", null: false
47
- end
48
-
49
- create_table "salaries", id: false, force: :cascade do |t|
50
- t.integer "emp_no", null: false
51
- t.integer "salary", null: false
52
- t.date "from_date", null: false
53
- t.date "to_date", null: false
54
- t.index ["emp_no"], name: "emp_no"
55
- end
56
-
57
- create_table "titles", id: false, force: :cascade do |t|
58
- t.integer "emp_no", null: false
59
- t.string "title", limit: 50, null: false
60
- t.date "from_date", null: false
61
- t.date "to_date"
62
- t.index ["emp_no"], name: "emp_no"
63
- end
64
- ERB
65
- end
66
-
67
- let(:expected_dsl) do
68
- erbh(<<-ERB)
69
- create_table "clubs", force: :cascade do |t|
70
- t.string "name", default: "", null: false
71
- t.index ["name"], name: "idx_name", unique: true
72
- end
73
-
74
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
75
- t.string "dept_name", limit: 40, null: false
76
- t.index ["dept_name"], name: "dept_name", unique: true
77
- end
78
-
79
- create_table "dept_emp", id: false, force: :cascade do |t|
80
- t.integer "emp_no", null: false
81
- t.string "dept_no", null: false
82
- t.date "from_date", null: false
83
- t.date "to_date", null: false
84
- t.index ["dept_no"], name: "dept_no"
85
- t.index ["emp_no"], name: "emp_no"
86
- end
87
-
88
- create_table "dept_manager", id: false, force: :cascade do |t|
89
- t.string "dept_no", null: false
90
- t.integer "emp_no", null: false
91
- t.date "from_date", null: false
92
- t.date "to_date", null: false
93
- t.index ["dept_no"], name: "dept_no"
94
- t.index ["emp_no"], name: "emp_no"
95
- end
96
-
97
- create_table "employee_clubs", force: :cascade do |t|
98
- t.integer "emp_no", null: false
99
- t.integer "club_id"
100
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
101
- end
102
-
103
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
104
- t.date "birth_date", null: false
105
- t.string "first_name", limit: 14, null: false
106
- t.string "last_name", limit: 20, default: "XXX", null: false
107
- t.string "gender", limit: 2, null: false
108
- t.date "hire_date", null: false
109
- end
110
-
111
- create_table "salaries", id: false, force: :cascade do |t|
112
- t.integer "emp_no", null: false
113
- t.integer "salary", null: false
114
- t.date "from_date", null: false
115
- t.date "to_date", null: false
116
- t.index ["emp_no"], name: "emp_no"
117
- end
118
-
119
- create_table "titles", id: false, force: :cascade do |t|
120
- t.integer "emp_no", null: false
121
- t.string "title", limit: 50, null: false
122
- t.date "from_date", null: false
123
- t.date "to_date"
124
- t.index ["emp_no"], name: "emp_no"
125
- end
126
- ERB
127
- end
128
-
129
- before { subject.diff(actual_dsl).migrate }
130
- subject { client }
131
-
132
- it {
133
- delta = subject.diff(expected_dsl)
134
- expect(delta.differ?).to be_truthy
135
- expect(subject.dump).to match_ruby actual_dsl
136
- delta.migrate
137
- expect(subject.dump).to match_ruby expected_dsl
138
- }
139
-
140
- it {
141
- delta = client(bulk_change: true).diff(expected_dsl)
142
- expect(delta.differ?).to be_truthy
143
- expect(subject.dump).to match_ruby actual_dsl
144
- expect(delta.script).to match_fuzzy erbh(<<-ERB)
145
- change_table("employee_clubs", bulk: true) do |t|
146
- t.change("club_id", :integer, **{:null=>true, :default=>nil, :unsigned=>false, :comment=>nil})
147
- end
148
-
149
- change_table("employees", bulk: true) do |t|
150
- t.change("last_name", :string, **{:limit=>20, :default=>"XXX", :unsigned=>false, :comment=>nil})
151
- t.change("gender", :string, **{:limit=>2, :null=>false, :default=>nil, :unsigned=>false, :comment=>nil})
152
- end
153
- ERB
154
- delta.migrate
155
- expect(subject.dump).to match_ruby expected_dsl
156
- }
157
- end
158
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change index (no change)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "salaries", id: false, force: :cascade do |t|
8
- t.integer "emp_no", null: false
9
- t.integer "salary", null: false
10
- t.date "from_date", null: false
11
- t.date "to_date", null: false
12
- t.index ["emp_no"], name: "emp_no"
13
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- erbh(<<-ERB)
19
- create_table "salaries", id: false, force: :cascade do |t|
20
- t.integer "emp_no", null: false
21
- t.integer "salary", null: false
22
- t.date "from_date", null: false
23
- t.date "to_date", null: false
24
- t.index "emp_no", name: "emp_no"
25
- end
26
- ERB
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client }
31
-
32
- it {
33
- delta = subject.diff(expected_dsl)
34
- expect(delta.differ?).to be_falsey
35
- }
36
- end
37
-
38
- context 'when change index (change)' do
39
- let(:actual_dsl) do
40
- erbh(<<-ERB)
41
- create_table "salaries", id: false, force: :cascade do |t|
42
- t.integer "emp_no", null: false
43
- t.integer "salary", null: false
44
- t.date "from_date", null: false
45
- t.date "to_date", null: false
46
- t.index ["emp_no"], name: "emp_no"
47
- end
48
- ERB
49
- end
50
-
51
- let(:dsl) do
52
- erbh(<<-ERB)
53
- create_table "salaries", id: false, force: :cascade do |t|
54
- t.integer "emp_no", null: false
55
- t.integer "salary", null: false
56
- t.date "from_date", null: false
57
- t.date "to_date", null: false
58
- t.index "salary", name: "emp_no"
59
- end
60
- ERB
61
- end
62
-
63
- let(:expected_dsl) do
64
- erbh(<<-ERB)
65
- create_table "salaries", id: false, force: :cascade do |t|
66
- t.integer "emp_no", null: false
67
- t.integer "salary", null: false
68
- t.date "from_date", null: false
69
- t.date "to_date", null: false
70
- t.index ["salary"], name: "emp_no"
71
- end
72
- ERB
73
- end
74
-
75
- before { subject.diff(actual_dsl).migrate }
76
- subject { client }
77
-
78
- it {
79
- delta = subject.diff(dsl)
80
- expect(delta.differ?).to be_truthy
81
- expect(subject.dump).to match_ruby actual_dsl
82
- delta.migrate
83
- expect(subject.dump).to match_ruby expected_dsl
84
- }
85
- end
86
- end
@@ -1,179 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change index without using (no change)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "salaries", id: false, force: :cascade do |t|
8
- t.integer "emp_no", null: false
9
- t.integer "salary", null: false
10
- t.date "from_date", null: false
11
- t.date "to_date", null: false
12
- t.index ["emp_no"], name: "emp_no"
13
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- <<-RUBY
19
- create_table "salaries", id: false, force: :cascade do |t|
20
- t.integer "emp_no", null: false
21
- t.integer "salary", null: false
22
- t.date "from_date", null: false
23
- t.date "to_date", null: false
24
- t.index ["emp_no"], name: "emp_no"
25
- end
26
- RUBY
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client }
31
-
32
- it {
33
- delta = subject.diff(expected_dsl)
34
- expect(delta.differ?).to be_falsey
35
- }
36
- end
37
-
38
- context 'when change index without using (change)' do
39
- let(:actual_dsl) do
40
- erbh(<<-ERB)
41
- create_table "salaries", id: false, force: :cascade do |t|
42
- t.integer "emp_no", null: false
43
- t.integer "salary", null: false
44
- t.date "from_date", null: false
45
- t.date "to_date", null: false
46
- t.index ["emp_no"], name: "emp_no"
47
- end
48
- ERB
49
- end
50
-
51
- let(:dsl) do
52
- <<-RUBY
53
- create_table "salaries", id: false, force: :cascade do |t|
54
- t.integer "emp_no", null: false
55
- t.integer "salary", null: false
56
- t.date "from_date", null: false
57
- t.date "to_date", null: false
58
- t.index ["salary"], using: :hash
59
- end
60
- RUBY
61
- end
62
-
63
- let(:expected_dsl) do
64
- <<-RUBY
65
- create_table "salaries", id: false, force: :cascade do |t|
66
- t.integer "emp_no", null: false
67
- t.integer "salary", null: false
68
- t.date "from_date", null: false
69
- t.date "to_date", null: false
70
- t.index ["salary"], name: "index_salaries_on_salary", using: :hash
71
- end
72
- RUBY
73
- end
74
-
75
- before { subject.diff(<<-RUBY).migrate }
76
- create_table "salaries", id: false, force: :cascade do |t|
77
- t.integer "emp_no", null: false
78
- t.integer "salary", null: false
79
- t.date "from_date", null: false
80
- t.date "to_date", null: false
81
- end
82
-
83
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
84
- RUBY
85
-
86
- subject { client(table_options: 'ENGINE=MEMORY') }
87
-
88
- it {
89
- delta = subject.diff(dsl)
90
- expect(delta.differ?).to be_truthy
91
- expect(subject.dump).to match_ruby actual_dsl
92
- delta.migrate
93
- expect(subject.dump).to match_ruby expected_dsl
94
- }
95
- end
96
-
97
- context 'when change index without name (no change)' do
98
- let(:actual_dsl) do
99
- erbh(<<-ERB)
100
- create_table "salaries", id: false, force: :cascade do |t|
101
- t.integer "emp_no", null: false
102
- t.integer "salary", null: false
103
- t.date "from_date", null: false
104
- t.date "to_date", null: false
105
- t.index ["emp_no"], name: "emp_no"
106
- end
107
- ERB
108
- end
109
-
110
- let(:expected_dsl) do
111
- erbh(<<-ERB)
112
- create_table "salaries", id: false, force: :cascade do |t|
113
- t.integer "emp_no", null: false
114
- t.integer "salary", null: false
115
- t.date "from_date", null: false
116
- t.date "to_date", null: false
117
- t.index ["emp_no"]
118
- end
119
- ERB
120
- end
121
-
122
- before { subject.diff(actual_dsl).migrate }
123
- subject { client }
124
-
125
- it {
126
- delta = subject.diff(expected_dsl)
127
- expect(delta.differ?).to be_falsey
128
- }
129
- end
130
-
131
- context 'when change index without name (change)' do
132
- let(:actual_dsl) do
133
- erbh(<<-ERB)
134
- create_table "salaries", id: false, force: :cascade do |t|
135
- t.integer "emp_no", null: false
136
- t.integer "salary", null: false
137
- t.date "from_date", null: false
138
- t.date "to_date", null: false
139
- t.index ["emp_no"], name: "emp_no"
140
- end
141
- ERB
142
- end
143
-
144
- let(:dsl) do
145
- erbh(<<-ERB)
146
- create_table "salaries", id: false, force: :cascade do |t|
147
- t.integer "emp_no", null: false
148
- t.integer "salary", null: false
149
- t.date "from_date", null: false
150
- t.date "to_date", null: false
151
- t.index ["salary"]
152
- end
153
- ERB
154
- end
155
-
156
- let(:expected_dsl) do
157
- erbh(<<-ERB)
158
- create_table "salaries", id: false, force: :cascade do |t|
159
- t.integer "emp_no", null: false
160
- t.integer "salary", null: false
161
- t.date "from_date", null: false
162
- t.date "to_date", null: false
163
- t.index ["salary"], name: "index_salaries_on_salary"
164
- end
165
- ERB
166
- end
167
-
168
- before { subject.diff(actual_dsl).migrate }
169
- subject { client }
170
-
171
- it {
172
- delta = subject.diff(dsl)
173
- expect(delta.differ?).to be_truthy
174
- expect(subject.dump).to match_ruby actual_dsl
175
- delta.migrate
176
- expect(subject.dump).to match_ruby expected_dsl
177
- }
178
- end
179
- end
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change index (same name)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "salaries", force: :cascade do |t|
8
- t.integer "emp_no", null: false
9
- t.integer "salary", null: false
10
- t.date "from_date", null: false
11
- t.date "to_date", null: false
12
- t.index ["emp_no", "id"], name: "emp_no"
13
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- erbh(<<-ERB)
19
- create_table "salaries", force: :cascade do |t|
20
- t.integer "emp_no", null: false
21
- t.integer "salary", null: false
22
- t.date "from_date", null: false
23
- t.date "to_date", null: false
24
- t.index ["salary", "id"], name: "emp_no"
25
- end
26
- ERB
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client }
31
-
32
- it {
33
- delta = subject.diff(expected_dsl)
34
- expect(delta.differ?).to be_truthy
35
- expect(subject.dump).to match_ruby actual_dsl
36
- delta.migrate
37
- expect(subject.dump).to match_ruby expected_dsl
38
- }
39
- end
40
-
41
- context 'when change index (same name) (2)' do
42
- let(:actual_dsl) do
43
- erbh(<<-ERB)
44
- create_table "salaries", id: false, force: :cascade do |t|
45
- t.integer "emp_no", null: false
46
- t.integer "salary", null: false
47
- t.date "from_date", null: false
48
- t.date "to_date", null: false
49
- t.index ["emp_no"], name: "emp_no"
50
- end
51
- ERB
52
- end
53
-
54
- let(:expected_dsl) do
55
- erbh(<<-ERB)
56
- create_table "salaries", id: false, force: :cascade do |t|
57
- t.integer "emp_no", null: false
58
- t.integer "salary", null: false
59
- t.date "from_date", null: false
60
- t.date "to_date", null: false
61
- t.index ["salary"], name: "emp_no"
62
- end
63
- ERB
64
- end
65
-
66
- before { subject.diff(actual_dsl).migrate }
67
- subject { client }
68
-
69
- it {
70
- delta = subject.diff(expected_dsl)
71
- expect(delta.differ?).to be_truthy
72
- expect(subject.dump).to match_ruby actual_dsl
73
- delta.migrate
74
- expect(subject.dump).to match_ruby expected_dsl
75
- }
76
- end
77
-
78
- context 'when change index (same name) (3)' do
79
- let(:actual_dsl) do
80
- erbh(<<-ERB)
81
- create_table "salaries", primary_key: "emp_no", force: :cascade do |t|
82
- t.integer "salary", null: false
83
- t.date "from_date", null: false
84
- t.date "to_date", null: false
85
- t.index ["salary", "emp_no"], name: "emp_no"
86
- end
87
- ERB
88
- end
89
-
90
- let(:expected_dsl) do
91
- erbh(<<-ERB)
92
- create_table "salaries", primary_key: "emp_no", force: :cascade do |t|
93
- t.integer "salary", null: false
94
- t.date "from_date", null: false
95
- t.date "to_date", null: false
96
- t.index ["from_date", "emp_no"], name: "emp_no"
97
- end
98
- ERB
99
- end
100
-
101
- before { subject.diff(actual_dsl).migrate }
102
- subject { client }
103
-
104
- it {
105
- delta = subject.diff(expected_dsl)
106
- expect(delta.differ?).to be_truthy
107
- expect(subject.dump).to match_ruby actual_dsl
108
- delta.migrate
109
- expect(subject.dump).to match_ruby expected_dsl
110
- }
111
- end
112
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change index (unique: false)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "salaries", force: :cascade do |t|
8
- t.integer "emp_no", null: false
9
- t.integer "salary", null: false
10
- t.date "from_date", null: false
11
- t.date "to_date", null: false
12
- t.index ["emp_no", "id"], name: "emp_no"
13
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- erbh(<<-ERB)
19
- create_table "salaries", force: :cascade do |t|
20
- t.integer "emp_no", null: false
21
- t.integer "salary", null: false
22
- t.date "from_date", null: false
23
- t.date "to_date", null: false
24
- t.index ["emp_no", "id"], name: "emp_no", unique: false
25
- end
26
- ERB
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client }
31
-
32
- it {
33
- delta = subject.diff(expected_dsl)
34
- expect(delta.differ?).to be_falsy
35
- }
36
- end
37
-
38
- context 'when change index (unique: true)' do
39
- let(:actual_dsl) do
40
- erbh(<<-ERB)
41
- create_table "salaries", force: :cascade do |t|
42
- t.integer "emp_no", null: false
43
- t.integer "salary", null: false
44
- t.date "from_date", null: false
45
- t.date "to_date", null: false
46
- t.index ["emp_no", "id"], name: "emp_no"
47
- end
48
- ERB
49
- end
50
-
51
- let(:expected_dsl) do
52
- erbh(<<-ERB)
53
- create_table "salaries", force: :cascade do |t|
54
- t.integer "emp_no", null: false
55
- t.integer "salary", null: false
56
- t.date "from_date", null: false
57
- t.date "to_date", null: false
58
- t.index ["emp_no", "id"], name: "emp_no", unique: true
59
- end
60
- ERB
61
- end
62
-
63
- before { subject.diff(actual_dsl).migrate }
64
- subject { client }
65
-
66
- it {
67
- delta = subject.diff(expected_dsl)
68
- expect(delta.differ?).to be_truthy
69
- expect(subject.dump).to match_ruby actual_dsl
70
- delta.migrate
71
- expect(subject.dump).to match_ruby expected_dsl
72
- }
73
- end
74
- end