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,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- subject { client }
5
-
6
- context 'when add_index contains expression' do
7
- let(:actual_dsl) { '' }
8
- let(:expected_dsl) { erbh(<<-ERB) }
9
- create_table "users", force: :cascade do |t|
10
- t.string "name", null: false
11
- t.datetime "created_at", null: false
12
- t.datetime "updated_at", null: false
13
- t.index "lower((name)::text)", name: "index_users_on_lower_name"
14
- end
15
- ERB
16
-
17
- specify do
18
- delta = subject.diff(expected_dsl)
19
- expect(delta).to be_differ
20
- expect(subject.dump).to match_fuzzy(actual_dsl)
21
- delta.migrate
22
- expect(subject.dump).to match_fuzzy(expected_dsl)
23
- end
24
- end
25
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when add bigint column' do
5
- let(:actual_dsl) { '' }
6
-
7
- let(:expected_dsl) do
8
- erbh(<<-ERB)
9
- create_table "bigint_test", id: false, force: :cascade do |t|
10
- t.bigint "b"
11
- end
12
- ERB
13
- end
14
-
15
- before { subject.diff(actual_dsl).migrate }
16
- subject { client }
17
-
18
- it {
19
- delta = subject.diff(expected_dsl)
20
- expect(delta.differ?).to be_truthy
21
- delta.migrate
22
- expect(subject.dump).to match_ruby expected_dsl
23
- }
24
- end
25
-
26
- context 'when no change' do
27
- let(:dsl) do
28
- erbh(<<-ERB)
29
- create_table "bigint_test", id: false, force: :cascade do |t|
30
- t.bigint "b"
31
- end
32
- ERB
33
- end
34
-
35
- let(:expected_dsl) do
36
- erbh(<<-ERB)
37
- create_table "bigint_test", id: false, force: :cascade do |t|
38
- t.bigint "b"
39
- end
40
- ERB
41
- end
42
-
43
- before { subject.diff(dsl).migrate }
44
- subject { client }
45
-
46
- it {
47
- delta = subject.diff(expected_dsl)
48
- expect(delta.differ?).to be_falsey
49
- delta.migrate
50
- expect(subject.dump).to match_ruby expected_dsl
51
- }
52
- end
53
- end
@@ -1,38 +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
- <<-RUBY
7
- create_table "salaries", id: false, force: :cascade do |t|
8
- t.integer "emp_no", default: 0, null: false
9
- t.integer "salary", null: false
10
- t.date "from_date", null: false
11
- t.date "to_date", null: false
12
- end
13
- RUBY
14
- end
15
-
16
- let(:expected_dsl) do
17
- <<-RUBY
18
- create_table "salaries", id: false, force: :cascade do |t|
19
- t.integer "emp_no", null: false
20
- t.integer "salary", null: false
21
- t.date "from_date", null: false
22
- t.date "to_date", null: false
23
- end
24
- RUBY
25
- end
26
-
27
- before { subject.diff(actual_dsl).migrate }
28
- subject { client }
29
-
30
- it {
31
- delta = subject.diff(expected_dsl)
32
- expect(delta.differ?).to be_truthy
33
- expect(subject.dump).to match_ruby actual_dsl
34
- delta.migrate
35
- expect(subject.dump).to match_ruby expected_dsl
36
- }
37
- end
38
- end
@@ -1,185 +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", limit: 255, 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
- end
15
-
16
- create_table "dept_emp", id: false, force: :cascade do |t|
17
- t.integer "emp_no", null: false
18
- t.string "dept_no", limit: 4, null: false
19
- t.date "from_date", null: false
20
- t.date "to_date", null: false
21
- t.index ["dept_no"], name: "idx_dept_emp_dept_no"
22
- t.index ["emp_no"], name: "idx_dept_emp_emp_no"
23
- end
24
-
25
- create_table "dept_manager", id: false, force: :cascade do |t|
26
- t.string "dept_no", limit: 4, null: false
27
- t.integer "emp_no", null: false
28
- t.date "from_date", null: false
29
- t.date "to_date", null: false
30
- t.index ["dept_no"], name: "idx_dept_manager_dept_no"
31
- t.index ["emp_no"], name: "idx_dept_manager_emp_no"
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
- t.index ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id"
38
- end
39
-
40
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
41
- t.date "birth_date", null: false
42
- t.string "first_name", limit: 14, null: false
43
- t.string "last_name", limit: 16, null: false
44
- t.date "hire_date", null: false
45
- end
46
-
47
- create_table "salaries", id: false, force: :cascade do |t|
48
- t.integer "emp_no", null: false
49
- t.integer "salary", null: false
50
- t.date "from_date", null: false
51
- t.date "to_date", null: false
52
- t.index ["emp_no"], name: "idx_salaries_emp_no"
53
- end
54
-
55
- create_table "titles", id: false, force: :cascade do |t|
56
- t.integer "emp_no", null: false
57
- t.string "title", limit: 50, null: false
58
- t.date "from_date", null: false
59
- t.date "to_date"
60
- t.index ["emp_no"], name: "idx_titles_emp_no"
61
- end
62
- ERB
63
- end
64
-
65
- let(:expected_dsl) do
66
- erbh(<<-ERB)
67
- create_table "clubs", force: :cascade do |t|
68
- t.string "name", limit: 255, default: "", null: false
69
- t.index ["name"], name: "idx_name", unique: true
70
- end
71
-
72
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
73
- t.string "dept_name", limit: 40, null: false
74
- end
75
-
76
- create_table "dept_emp", id: false, force: :cascade do |t|
77
- t.integer "emp_no", null: false
78
- t.string "dept_no", limit: 4, null: false
79
- t.date "from_date", null: false
80
- t.date "to_date", null: false
81
- t.index ["dept_no"], name: "idx_dept_emp_dept_no"
82
- t.index ["emp_no"], name: "idx_dept_emp_emp_no"
83
- end
84
-
85
- create_table "dept_manager", id: false, force: :cascade do |t|
86
- t.string "dept_no", limit: 4, null: false
87
- t.integer "emp_no", null: false
88
- t.date "from_date", null: false
89
- t.date "to_date", null: false
90
- t.index ["dept_no"], name: "idx_dept_manager_dept_no"
91
- t.index ["emp_no"], name: "idx_dept_manager_emp_no"
92
- end
93
-
94
- create_table "employee_clubs", force: :cascade do |t|
95
- t.integer "emp_no", null: false
96
- t.integer "club_id"
97
- t.index ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id"
98
- end
99
-
100
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
101
- t.date "birth_date", null: false
102
- t.string "first_name", limit: 14, null: false
103
- t.string "last_name", limit: 20, default: "XXX", null: false
104
- t.date "hire_date", null: false
105
- end
106
-
107
- create_table "salaries", id: false, force: :cascade do |t|
108
- t.integer "emp_no", null: false
109
- t.integer "salary", null: false
110
- t.date "from_date", null: false
111
- t.date "to_date", null: false
112
- t.index ["emp_no"], name: "idx_salaries_emp_no"
113
- end
114
-
115
- create_table "titles", id: false, force: :cascade do |t|
116
- t.integer "emp_no", null: false
117
- t.string "title", limit: 50, null: false
118
- t.date "from_date", null: false
119
- t.date "to_date"
120
- t.index ["emp_no"], name: "idx_titles_emp_no"
121
- end
122
- ERB
123
- end
124
-
125
- before { subject.diff(actual_dsl).migrate }
126
- subject { client }
127
-
128
- it {
129
- delta = subject.diff(expected_dsl)
130
- expect(delta.differ?).to be_truthy
131
- expect(subject.dump).to match_ruby actual_dsl
132
- delta.migrate
133
- expect(subject.dump).to match_ruby expected_dsl
134
- }
135
-
136
- it {
137
- delta = client(bulk_change: true).diff(expected_dsl)
138
- expect(delta.differ?).to be_truthy
139
- expect(subject.dump).to match_ruby actual_dsl
140
- expect(delta.script).to match_fuzzy <<-RUBY
141
- change_table("employee_clubs", bulk: true) do |t|
142
- t.change("club_id", :integer, **{:null=>true, :default=>nil})
143
- end
144
-
145
- change_table("employees", bulk: true) do |t|
146
- t.change("last_name", :string, **{:limit=>20, :default=>"XXX"})
147
- end
148
- RUBY
149
- delta.migrate
150
- expect(subject.dump).to match_ruby expected_dsl
151
- }
152
- end
153
-
154
- context 'when string/text without limit (no change)' do
155
- let(:actual_dsl) do
156
- erbh(<<-ERB)
157
- create_table "clubs", force: :cascade do |t|
158
- t.string "name", default: "", null: false
159
- t.text "desc"
160
- t.serial "club_no"
161
- t.bigserial "club_bigno"
162
- end
163
- ERB
164
- end
165
-
166
- let(:expected_dsl) do
167
- erbh(<<-ERB)
168
- create_table "clubs", force: :cascade do |t|
169
- t.string "name", default: "", null: false
170
- t.text "desc"
171
- t.serial "club_no"
172
- t.bigserial "club_bigno"
173
- end
174
- ERB
175
- end
176
-
177
- before { subject.diff(actual_dsl).migrate }
178
- subject { client }
179
-
180
- it {
181
- delta = subject.diff(expected_dsl)
182
- expect(delta.differ?).to be_falsey
183
- }
184
- end
185
- end
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change index' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "clubs", force: :cascade do |t|
8
- t.string "name", limit: 255, 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: "idx_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", limit: 4, null: false
20
- t.date "from_date", null: false
21
- t.date "to_date", null: false
22
- t.index ["dept_no"], name: "idx_dept_emp_dept_no"
23
- t.index ["emp_no"], name: "idx_dept_emp_emp_no"
24
- end
25
-
26
- create_table "dept_manager", id: false, force: :cascade do |t|
27
- t.string "dept_no", limit: 4, 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: "idx_dept_manager_dept_no"
32
- t.index ["emp_no"], name: "idx_dept_manager_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_employee_clubs_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.date "hire_date", null: false
46
- end
47
-
48
- create_table "salaries", id: false, force: :cascade do |t|
49
- t.integer "emp_no", null: false
50
- t.integer "salary", null: false
51
- t.date "from_date", null: false
52
- t.date "to_date", null: false
53
- t.index ["emp_no"], name: "idx_salaries_emp_no"
54
- end
55
-
56
- create_table "titles", id: false, force: :cascade do |t|
57
- t.integer "emp_no", null: false
58
- t.string "title", limit: 50, null: false
59
- t.date "from_date", null: false
60
- t.date "to_date"
61
- t.index ["emp_no"], name: "idx_titles_emp_no"
62
- end
63
- ERB
64
- end
65
-
66
- let(:expected_dsl) do
67
- erbh(<<-ERB)
68
- create_table "clubs", force: :cascade do |t|
69
- t.string "name", limit: 255, default: "", null: false
70
- t.index ["name"], name: "idx_name", unique: true
71
- end
72
-
73
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
74
- t.string "dept_name", limit: 40, null: false
75
- t.index ["dept_name"], name: "idx_dept_name", unique: true
76
- end
77
-
78
- create_table "dept_emp", id: false, force: :cascade do |t|
79
- t.integer "emp_no", null: false
80
- t.string "dept_no", limit: 4, null: false
81
- t.date "from_date", null: false
82
- t.date "to_date", null: false
83
- t.index ["dept_no"], name: "idx_dept_emp_dept_no"
84
- t.index ["from_date"], name: "idx_dept_emp_emp_no"
85
- end
86
-
87
- create_table "dept_manager", id: false, force: :cascade do |t|
88
- t.string "dept_no", limit: 4, null: false
89
- t.integer "emp_no", null: false
90
- t.date "from_date", null: false
91
- t.date "to_date", null: false
92
- t.index ["dept_no"], name: "idx_dept_manager_dept_no"
93
- t.index ["from_date"], name: "idx_dept_manager_emp_no"
94
- end
95
-
96
- create_table "employee_clubs", force: :cascade do |t|
97
- t.integer "emp_no", null: false
98
- t.integer "club_id", null: false
99
- t.index ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id"
100
- end
101
-
102
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
103
- t.date "birth_date", null: false
104
- t.string "first_name", limit: 14, null: false
105
- t.string "last_name", limit: 16, null: false
106
- t.date "hire_date", null: false
107
- end
108
-
109
- create_table "salaries", id: false, force: :cascade do |t|
110
- t.integer "emp_no", null: false
111
- t.integer "salary", null: false
112
- t.date "from_date", null: false
113
- t.date "to_date", null: false
114
- t.index ["from_date"], name: "idx_salaries_emp_no"
115
- end
116
-
117
- create_table "titles", id: false, force: :cascade do |t|
118
- t.integer "emp_no", null: false
119
- t.string "title", limit: 50, null: false
120
- t.date "from_date", null: false
121
- t.date "to_date"
122
- t.index ["emp_no"], name: "idx_titles_emp_no"
123
- end
124
- ERB
125
- end
126
-
127
- before { subject.diff(actual_dsl).migrate }
128
- subject { client }
129
-
130
- it {
131
- delta = subject.diff(expected_dsl)
132
- expect(delta.differ?).to be_truthy
133
- expect(subject.dump).to match_ruby actual_dsl
134
- delta.migrate
135
- expect(subject.dump).to match_ruby expected_dsl
136
- }
137
-
138
- it {
139
- delta = client(bulk_change: true).diff(expected_dsl)
140
- expect(delta.differ?).to be_truthy
141
- expect(subject.dump).to match_ruby actual_dsl
142
- expect(delta.script).to match_fuzzy <<-RUBY
143
- change_table("dept_emp", bulk: true) do |t|
144
- t.remove_index(name: "idx_dept_emp_emp_no")
145
- t.index(["from_date"], **{:name=>"idx_dept_emp_emp_no", :using=>:btree, :unique=>false})
146
- end
147
-
148
- change_table("dept_manager", bulk: true) do |t|
149
- t.remove_index(name: "idx_dept_manager_emp_no")
150
- t.index(["from_date"], **{:name=>"idx_dept_manager_emp_no", :using=>:btree, :unique=>false})
151
- end
152
-
153
- change_table("salaries", bulk: true) do |t|
154
- t.remove_index(name: "idx_salaries_emp_no")
155
- t.index(["from_date"], **{:name=>"idx_salaries_emp_no", :using=>:btree, :unique=>false})
156
- end
157
- RUBY
158
-
159
- expect do
160
- delta.migrate
161
- end.to_not raise_error
162
- }
163
- end
164
- end