ridgepole 0.9.2 → 0.9.6

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