ridgepole 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/lib/ridgepole/delta.rb +1 -1
  4. data/lib/ridgepole/version.rb +1 -1
  5. data/ridgepole.gemspec +5 -2
  6. metadata +3 -279
  7. data/.github/workflows/test.yml +0 -70
  8. data/.gitignore +0 -25
  9. data/spec/cli_helper.rb +0 -65
  10. data/spec/dsl_parser/context_spec.rb +0 -16
  11. data/spec/erb_helper.rb +0 -26
  12. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  13. data/spec/hide_pending_formatter.rb +0 -9
  14. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  15. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  16. data/spec/mysql/cli/config_spec.rb +0 -210
  17. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  18. data/spec/mysql/collation/collation_spec.rb +0 -153
  19. data/spec/mysql/comment/comment_spec.rb +0 -179
  20. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  21. data/spec/mysql/diff/diff2_spec.rb +0 -189
  22. data/spec/mysql/diff/diff_spec.rb +0 -168
  23. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  24. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  25. data/spec/mysql/dump/dump_spec.rb +0 -74
  26. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  27. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  28. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  29. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  30. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  31. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  32. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  33. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  34. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  35. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  36. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  37. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  38. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -276
  39. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  40. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  41. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  42. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  43. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  44. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  45. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
  46. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  47. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  48. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  49. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  50. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  51. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  52. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  53. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  54. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  55. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  56. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  57. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  58. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  59. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  60. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  61. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  62. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  63. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  64. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  65. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  66. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  67. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  68. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  69. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  70. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  71. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  72. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  73. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  74. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  75. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  76. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  77. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  78. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  79. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  80. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  81. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  82. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  83. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  84. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  85. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  86. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  87. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  88. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  89. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  90. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  91. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  92. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  93. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  94. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  95. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  96. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  97. data/spec/mysql/ridgepole_test_database.sql +0 -2
  98. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  99. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  100. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  101. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  102. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  103. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  104. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  105. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  106. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  107. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  108. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  109. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  110. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  111. data/spec/postgresql/diff/diff_spec.rb +0 -216
  112. data/spec/postgresql/dump/dump_spec.rb +0 -69
  113. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  114. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  115. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  116. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  117. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  118. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  119. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  120. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  121. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  122. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  123. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  124. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  125. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  126. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  127. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  128. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  129. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  130. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  131. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  132. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  133. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  134. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  135. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  136. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  137. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  138. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  139. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  140. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  141. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  142. data/spec/processing_for_ci.rb +0 -13
  143. data/spec/spec_condition.rb +0 -58
  144. data/spec/spec_const.rb +0 -20
  145. data/spec/spec_helper.rb +0 -173
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when create index with ignore:true' do
5
- let(: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, ignore: true
10
- end
11
-
12
- create_table "employee_clubs", force: :cascade do |t|
13
- t.integer "emp_no", null: false
14
- t.integer "club_id", null: false
15
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", ignore: true
16
- end
17
-
18
- create_table "titles", id: false, force: :cascade do |t|
19
- t.integer "emp_no", null: false
20
- t.string "title", limit: 50, null: false
21
- t.date "from_date", null: false
22
- t.date "to_date"
23
- t.index ["emp_no"], name: "emp_no", ignore: true
24
- end
25
- ERB
26
- end
27
-
28
- let(:actual_dsl) do
29
- erbh(<<-ERB)
30
- create_table "clubs", force: :cascade do |t|
31
- t.string "name", default: "", null: false
32
- end
33
-
34
- create_table "employee_clubs", force: :cascade do |t|
35
- t.integer "emp_no", null: false
36
- t.integer "club_id", null: false
37
- end
38
-
39
- create_table "titles", id: false, force: :cascade do |t|
40
- t.integer "emp_no", null: false
41
- t.string "title", limit: 50, null: false
42
- t.date "from_date", null: false
43
- t.date "to_date"
44
- end
45
- ERB
46
- end
47
-
48
- let(:expected_dsl) { dsl }
49
-
50
- before { subject.diff(actual_dsl).migrate }
51
- subject { client }
52
-
53
- it {
54
- delta = subject.diff(expected_dsl)
55
- expect(delta.differ?).to be_falsey
56
- }
57
- end
58
-
59
- context 'when change index with ignore:true' do
60
- let(:actual_dsl) do
61
- erbh(<<-ERB)
62
- create_table "salaries", id: false, force: :cascade do |t|
63
- t.integer "emp_no", null: false
64
- t.integer "salary", null: false
65
- t.date "from_date", null: false
66
- t.date "to_date", null: false
67
- t.index ["emp_no"], name: "emp_no"
68
- end
69
- ERB
70
- end
71
-
72
- let(:expected_dsl) do
73
- erbh(<<-ERB)
74
- create_table "salaries", id: false, force: :cascade do |t|
75
- t.integer "emp_no", null: false
76
- t.integer "salary", null: false
77
- t.date "from_date", null: false
78
- t.date "to_date", null: false
79
- t.index ["from_date"], name: "emp_no", ignore: true
80
- end
81
- ERB
82
- end
83
-
84
- before { subject.diff(actual_dsl).migrate }
85
- subject { client }
86
-
87
- it {
88
- delta = subject.diff(expected_dsl)
89
- expect(delta.differ?).to be_falsey
90
- }
91
- end
92
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when create table' do
5
- let(: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(:actual_dsl) do
68
- erbh(<<-ERB)
69
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
70
- t.string "dept_name", limit: 40, null: false
71
- t.index ["dept_name"], name: "dept_name", unique: true
72
- end
73
-
74
- create_table "dept_emp", id: false, force: :cascade do |t|
75
- t.integer "emp_no", null: false
76
- t.string "dept_no", null: false
77
- t.date "from_date", null: false
78
- t.date "to_date", null: false
79
- t.index ["dept_no"], name: "dept_no"
80
- t.index ["emp_no"], name: "emp_no"
81
- end
82
-
83
- create_table "dept_manager", id: false, force: :cascade do |t|
84
- t.string "dept_no", null: false
85
- t.integer "emp_no", null: false
86
- t.date "from_date", null: false
87
- t.date "to_date", null: false
88
- t.index ["dept_no"], name: "dept_no"
89
- t.index ["emp_no"], name: "emp_no"
90
- end
91
-
92
- create_table "salaries", id: false, force: :cascade do |t|
93
- t.integer "emp_no", null: false
94
- t.integer "salary", null: false
95
- t.date "from_date", null: false
96
- t.date "to_date", null: false
97
- t.index ["emp_no"], name: "emp_no"
98
- end
99
-
100
- create_table "titles", id: false, force: :cascade do |t|
101
- t.integer "emp_no", null: false
102
- t.string "title", limit: 50, null: false
103
- t.date "from_date", null: false
104
- t.date "to_date"
105
- t.index ["emp_no"], name: "emp_no"
106
- end
107
- ERB
108
- end
109
-
110
- let(:expected_dsl) { dsl }
111
-
112
- before { client.diff(actual_dsl).migrate }
113
-
114
- it {
115
- tempfile("#{File.basename __FILE__}.#{$PROCESS_ID}") do |path|
116
- delta = client(log_file: path).diff(expected_dsl)
117
- expect(delta.differ?).to be_truthy
118
- expect(client.dump).to match_ruby actual_dsl
119
- delta.migrate
120
- expect(client.dump).to match_ruby expected_dsl
121
- expect(File.size(path)).to be > 0
122
- end
123
- }
124
- end
125
- end
@@ -1,145 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when marge table' 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 "clubs2", force: :cascade do |t|
75
- t.string "name2", default: "", null: false
76
- end
77
-
78
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
79
- t.string "dept_name", limit: 40, null: false
80
- t.index ["dept_name"], name: "dept_name", unique: true
81
- end
82
-
83
- create_table "dept_emp", id: false, force: :cascade do |t|
84
- t.integer "emp_no", null: false
85
- t.string "dept_no", null: false
86
- t.date "from_date", null: false
87
- t.date "to_date", null: false
88
- t.index ["dept_no"], name: "dept_no"
89
- t.index ["emp_no"], name: "emp_no"
90
- end
91
-
92
- create_table "dept_manager", id: false, force: :cascade do |t|
93
- t.string "dept_no", null: false
94
- t.integer "emp_no", null: false
95
- t.date "from_date", null: false
96
- t.date "to_date", null: false
97
- t.index ["dept_no"], name: "dept_no"
98
- t.index ["emp_no"], name: "emp_no"
99
- end
100
-
101
- create_table "employee_clubs", force: :cascade do |t|
102
- t.integer "emp_no", null: false
103
- t.integer "club_id", null: false
104
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
105
- end
106
-
107
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
108
- t.date "birth_date", null: false
109
- t.string "first_name", limit: 14, null: false
110
- t.string "last_name", limit: 16, null: false
111
- t.string "gender", limit: 1, null: false
112
- t.date "hire_date", null: false
113
- end
114
-
115
- create_table "salaries", id: false, force: :cascade do |t|
116
- t.integer "emp_no", null: false
117
- t.integer "salary", null: false
118
- t.date "from_date", null: false
119
- t.date "to_date", null: false
120
- t.index ["emp_no"], name: "emp_no"
121
- end
122
-
123
- create_table "titles", id: false, force: :cascade do |t|
124
- t.integer "emp_no", null: false
125
- t.string "title", limit: 50, null: false
126
- t.date "from_date", null: false
127
- t.date "to_date"
128
- t.index ["emp_no"], name: "emp_no"
129
- end
130
- ERB
131
- end
132
-
133
- before { subject.diff(actual_dsl).migrate }
134
- subject { client(merge: true) }
135
-
136
- it {
137
- delta = subject.diff(expected_dsl.gsub(/create_table "clubs".+\n\s*t\..+\n\s*end/, ''))
138
- expect(delta.differ?).to be_truthy
139
- expect(subject.dump).to match_ruby actual_dsl
140
- delta.migrate
141
- # `clubs` table is not deleted
142
- expect(subject.dump).to match_ruby expected_dsl
143
- }
144
- end
145
- end
@@ -1,234 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when no operation' do
5
- let(:actual_dsl) { '' }
6
- let(:expected_dsl) do
7
- <<-RUBY
8
- create_table "clubs", force: :cascade 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: :cascade 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: :cascade 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: :cascade 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: :cascade do |t|
41
- t.integer "emp_no", null: false, unsigned: true
42
- t.integer "club_id", null: false, unsigned: true
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: :cascade 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: :cascade 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: :cascade 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
- end
74
-
75
- subject { client }
76
-
77
- it {
78
- delta = subject.diff(expected_dsl)
79
- expect(delta.differ?).to be_truthy
80
- migrated, sql = delta.migrate(noop: true)
81
- expect(migrated).to be_truthy
82
- expect(subject.dump).to match_ruby actual_dsl
83
-
84
- expect(sql).to match_fuzzy erbh(<<-ERB)
85
- CREATE TABLE `clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
86
- CREATE UNIQUE INDEX `idx_name` USING btree ON `clubs` (`name`)
87
- CREATE TABLE `departments` (`dept_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `dept_name` varchar(40) NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
88
- CREATE UNIQUE INDEX `dept_name` USING btree ON `departments` (`dept_name`)
89
- CREATE TABLE `dept_emp` (`emp_no` int NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
90
- CREATE INDEX `dept_no` USING btree ON `dept_emp` (`dept_no`)
91
- CREATE INDEX `emp_no` USING btree ON `dept_emp` (`emp_no`)
92
- CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
93
- CREATE INDEX `dept_no` USING btree ON `dept_manager` (`dept_no`)
94
- CREATE INDEX `emp_no` USING btree ON `dept_manager` (`emp_no`)
95
- CREATE TABLE `employee_clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
96
- CREATE INDEX `idx_emp_no_club_id` USING btree ON `employee_clubs` (`emp_no`, `club_id`)
97
- CREATE TABLE `employees` (`emp_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` varchar(1) NOT NULL, `hire_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
98
- CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
99
- CREATE INDEX `emp_no` USING btree ON `salaries` (`emp_no`)
100
- CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
101
- CREATE INDEX `emp_no` USING btree ON `titles` (`emp_no`)
102
- ERB
103
- }
104
-
105
- it {
106
- delta = client(bulk_change: true).diff(expected_dsl)
107
- expect(delta.differ?).to be_truthy
108
- migrated, sql = delta.migrate(noop: true)
109
- expect(migrated).to be_truthy
110
- expect(subject.dump).to match_ruby actual_dsl
111
-
112
- # XXX:
113
- expect(sql.delete('`')).to match_fuzzy erbh(<<-ERB).delete('`')
114
- CREATE TABLE `clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
115
- ALTER TABLE `clubs` ADD UNIQUE INDEX `idx_name` USING btree (`name`)
116
- CREATE TABLE `departments` (`dept_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `dept_name` varchar(40) NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
117
- ALTER TABLE `departments` ADD UNIQUE INDEX `dept_name` USING btree (`dept_name`)
118
- CREATE TABLE `dept_emp` (`emp_no` int NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
119
- ALTER TABLE `dept_emp` ADD INDEX `dept_no` USING btree (`dept_no`), ADD INDEX `emp_no` USING btree (`emp_no`)
120
- CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
121
- ALTER TABLE `dept_manager` ADD INDEX `dept_no` USING btree (`dept_no`), ADD INDEX `emp_no` USING btree (`emp_no`)
122
- CREATE TABLE `employee_clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
123
- ALTER TABLE `employee_clubs` ADD INDEX `idx_emp_no_club_id` USING btree (`emp_no`, `club_id`)
124
- CREATE TABLE `employees` (`emp_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` varchar(1) NOT NULL, `hire_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
125
- CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
126
- ALTER TABLE `salaries` ADD INDEX `emp_no` USING btree (`emp_no`)
127
- CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
128
- ALTER TABLE `titles` ADD INDEX `emp_no` USING btree (`emp_no`)
129
- ERB
130
- }
131
- end
132
-
133
- context 'when no operation' do
134
- let(:actual_dsl) { '' }
135
- let(:expected_dsl) do
136
- <<-RUBY
137
- create_table "clubs", force: :cascade do |t|
138
- t.string "name", default: "", null: false
139
- end
140
-
141
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
142
-
143
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
144
- t.string "dept_name", limit: 40, null: false
145
- end
146
-
147
- add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
148
-
149
- create_table "dept_emp", id: false, force: :cascade do |t|
150
- t.integer "emp_no", null: false
151
- t.string "dept_no", limit: 4, null: false
152
- t.date "from_date", null: false
153
- t.date "to_date", null: false
154
- end
155
-
156
- add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
157
- add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
158
-
159
- create_table "dept_manager", id: false, force: :cascade do |t|
160
- t.string "dept_no", limit: 4, null: false
161
- t.integer "emp_no", limit: 4, null: false
162
- t.date "from_date", null: false
163
- t.date "to_date", null: false
164
- end
165
-
166
- add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
167
- add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
168
-
169
- create_table "employee_clubs", force: :cascade do |t|
170
- t.integer "emp_no", null: false, unsigned: true
171
- t.integer "club_id", null: false, unsigned: true
172
- end
173
-
174
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
175
-
176
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
177
- t.date "birth_date", null: false
178
- t.string "first_name", limit: 14, null: false
179
- t.string "last_name", limit: 16, null: false
180
- t.string "gender", limit: 1, null: false
181
- t.date "hire_date", null: false
182
- end
183
-
184
- create_table "salaries", id: false, force: :cascade do |t|
185
- t.integer "emp_no", null: false
186
- t.integer "salary", null: false
187
- t.date "from_date", null: false
188
- t.date "to_date", null: false
189
- end
190
-
191
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
192
-
193
- create_table "titles", id: false, force: :cascade do |t|
194
- t.integer "emp_no", null: false
195
- t.string "title", limit: 50, null: false
196
- t.date "from_date", null: false
197
- t.date "to_date"
198
- end
199
-
200
- add_index "titles", ["emp_no"], name: "emp_no", using: :btree
201
- RUBY
202
- end
203
-
204
- subject { client(default_int_limit: 11) }
205
-
206
- it {
207
- delta = subject.diff(expected_dsl)
208
- expect(delta.differ?).to be_truthy
209
- migrated, sql = delta.migrate(noop: true)
210
- expect(migrated).to be_truthy
211
- expect(subject.dump).to match_ruby actual_dsl
212
-
213
- expect(sql).to match_fuzzy erbh(<<-ERB)
214
- CREATE TABLE `clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
215
- CREATE UNIQUE INDEX `idx_name` USING btree ON `clubs` (`name`)
216
- CREATE TABLE `departments` (`dept_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `dept_name` varchar(40) NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
217
- CREATE UNIQUE INDEX `dept_name` USING btree ON `departments` (`dept_name`)
218
- CREATE TABLE `dept_emp` (`emp_no` int NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
219
- CREATE INDEX `dept_no` USING btree ON `dept_emp` (`dept_no`)
220
- CREATE INDEX `emp_no` USING btree ON `dept_emp` (`emp_no`)
221
- CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
222
- CREATE INDEX `dept_no` USING btree ON `dept_manager` (`dept_no`)
223
- CREATE INDEX `emp_no` USING btree ON `dept_manager` (`emp_no`)
224
- CREATE TABLE `employee_clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
225
- CREATE INDEX `idx_emp_no_club_id` USING btree ON `employee_clubs` (`emp_no`, `club_id`)
226
- CREATE TABLE `employees` (`emp_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` varchar(1) NOT NULL, `hire_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
227
- CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
228
- CREATE INDEX `emp_no` USING btree ON `salaries` (`emp_no`)
229
- CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
230
- CREATE INDEX `emp_no` USING btree ON `titles` (`emp_no`)
231
- ERB
232
- }
233
- end
234
- end