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,179 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change column (add comment)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "employee_clubs", force: :cascade do |t|
8
- t.integer "emp_no", null: false
9
- t.integer "club_id", null: false
10
- t.string "string", null: false
11
- t.text "text", null: false
12
- end
13
- ERB
14
- end
15
-
16
- let(:expected_dsl) do
17
- erbh(<<-ERB)
18
- create_table "employee_clubs", force: :cascade do |t|
19
- t.integer "emp_no", null: false, comment: "any comment"
20
- t.integer "club_id", null: false, comment: "any comment2"
21
- t.string "string", null: false, comment: "any comment3"
22
- t.text "text", null: false, comment: "any comment4"
23
- end
24
- ERB
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
-
39
- context 'when change column (delete comment)' do
40
- let(:actual_dsl) do
41
- erbh(<<-ERB)
42
- create_table "employee_clubs", force: :cascade do |t|
43
- t.integer "emp_no", null: false, comment: "any comment"
44
- t.integer "club_id", null: false, comment: "any comment2"
45
- t.string "string", null: false, comment: "any comment3"
46
- t.text "text", null: false, comment: "any comment4"
47
- end
48
- ERB
49
- end
50
-
51
- let(:expected_dsl) do
52
- erbh(<<-ERB)
53
- create_table "employee_clubs", force: :cascade do |t|
54
- t.integer "emp_no", null: false
55
- t.integer "club_id", null: false
56
- t.string "string", null: false
57
- t.text "text", null: false
58
- end
59
- ERB
60
- end
61
-
62
- before { subject.diff(actual_dsl).migrate }
63
- subject { client }
64
-
65
- it {
66
- delta = subject.diff(expected_dsl)
67
- expect(delta.differ?).to be_truthy
68
- expect(subject.dump).to match_ruby actual_dsl
69
- delta.migrate
70
- expect(subject.dump).to match_ruby expected_dsl
71
- }
72
- end
73
-
74
- context 'when change column (change comment)' do
75
- let(:actual_dsl) do
76
- erbh(<<-ERB)
77
- create_table "employee_clubs", force: :cascade do |t|
78
- t.integer "emp_no", null: false, comment: "any comment"
79
- t.integer "club_id", null: false, comment: "any comment2"
80
- t.string "string", null: false, comment: "any comment3"
81
- t.text "text", null: false, comment: "any comment4"
82
- end
83
- ERB
84
- end
85
-
86
- let(:expected_dsl) do
87
- erbh(<<-ERB)
88
- create_table "employee_clubs", force: :cascade do |t|
89
- t.integer "emp_no", null: false, comment: "other comment"
90
- t.integer "club_id", null: false, comment: "other comment2"
91
- t.string "string", null: false, comment: "other comment3"
92
- t.text "text", null: false, comment: "other comment4"
93
- end
94
- ERB
95
- end
96
-
97
- before { subject.diff(actual_dsl).migrate }
98
- subject { client }
99
-
100
- it {
101
- delta = subject.diff(expected_dsl)
102
- expect(delta.differ?).to be_truthy
103
- expect(subject.dump).to match_ruby actual_dsl
104
- delta.migrate
105
- expect(subject.dump).to match_ruby expected_dsl
106
- }
107
- end
108
-
109
- context 'when change column (no change comment)' do
110
- let(:actual_dsl) do
111
- erbh(<<-ERB)
112
- create_table "employee_clubs", force: :cascade do |t|
113
- t.integer "emp_no", null: false, comment: "any comment"
114
- t.integer "club_id", null: false, comment: "any comment2"
115
- t.string "string", null: false, comment: "any comment3"
116
- t.text "text", null: false, comment: "any comment4"
117
- end
118
- ERB
119
- end
120
-
121
- before { subject.diff(actual_dsl).migrate }
122
- subject { client }
123
-
124
- it {
125
- delta = subject.diff(actual_dsl)
126
- expect(delta.differ?).to be_falsey
127
- expect(subject.dump).to match_ruby actual_dsl
128
- delta.migrate
129
- expect(subject.dump).to match_ruby actual_dsl
130
- }
131
- end
132
-
133
- context 'when create table (with comment)' do
134
- let(:expected_dsl) do
135
- erbh(<<-ERB)
136
- create_table "employee_clubs", force: :cascade, comment: "table comment" do |t|
137
- t.integer "emp_no", null: false, comment: "other comment"
138
- t.integer "club_id", null: false, comment: "other comment2"
139
- t.string "string", null: false, comment: "other comment3"
140
- t.text "text", null: false, comment: "other comment4"
141
- end
142
- ERB
143
- end
144
-
145
- subject { client }
146
-
147
- it {
148
- delta = subject.diff(expected_dsl)
149
- expect(delta.differ?).to be_truthy
150
- expect(subject.dump.strip).to be_empty
151
- delta.migrate
152
- expect(subject.dump).to match_ruby expected_dsl
153
- }
154
- end
155
-
156
- context 'when drop table (with comment)' do
157
- let(:actual_dsl) do
158
- erbh(<<-ERB)
159
- create_table "employee_clubs", force: :cascade, comment: "table comment" do |t|
160
- t.integer "emp_no", null: false, comment: "other comment"
161
- t.integer "club_id", null: false, comment: "other comment2"
162
- t.string "string", null: false, comment: "other comment3"
163
- t.text "text", null: false, comment: "other comment4"
164
- end
165
- ERB
166
- end
167
-
168
- before { subject.diff(actual_dsl).migrate }
169
- subject { client }
170
-
171
- it {
172
- delta = subject.diff('')
173
- expect(delta.differ?).to be_truthy
174
- expect(subject.dump).to match_ruby actual_dsl
175
- delta.migrate
176
- expect(subject.dump).to be_empty
177
- }
178
- end
179
- end
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client (use default:lambda)' do
4
- context 'when create table with default:lambda' do
5
- subject { client }
6
-
7
- it do
8
- delta = subject.diff(<<-RUBY)
9
- create_table "foos", force: :cascade do |t|
10
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
11
- end
12
- RUBY
13
-
14
- expect(delta.differ?).to be_truthy
15
- delta.migrate
16
-
17
- expect(subject.dump).to match_fuzzy <<-RUBY
18
- create_table "foos", force: :cascade do |t|
19
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
20
- end
21
- RUBY
22
- end
23
- end
24
-
25
- context 'when there is no difference' do
26
- let(:dsl) do
27
- <<-RUBY
28
- create_table "foos", force: :cascade do |t|
29
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
30
- end
31
- RUBY
32
- end
33
-
34
- subject { client }
35
-
36
- before do
37
- subject.diff(dsl).migrate
38
- end
39
-
40
- it do
41
- delta = subject.diff(dsl)
42
- expect(delta.differ?).to be_falsey
43
- end
44
- end
45
-
46
- context 'when change column (1)' do
47
- subject { client }
48
-
49
- before do
50
- subject.diff(<<-RUBY).migrate
51
- create_table "foos", force: :cascade do |t|
52
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
53
- end
54
- RUBY
55
- end
56
-
57
- it do
58
- delta = subject.diff(<<-RUBY)
59
- create_table "foos", force: :cascade do |t|
60
- t.datetime "bar", default: -> { '"1970-01-01 00:00:00"' }, null: false
61
- end
62
- RUBY
63
-
64
- expect(delta.differ?).to be_truthy
65
- delta.migrate
66
-
67
- expect(subject.dump).to match_ruby erbh(<<-ERB)
68
- create_table "foos", force: :cascade do |t|
69
- t.datetime "bar", default: "1970-01-01 00:00:00", null: false
70
- end
71
- ERB
72
- end
73
- end
74
-
75
- context 'when change column (2)' do
76
- subject { client }
77
-
78
- before do
79
- subject.diff(<<-RUBY).migrate
80
- create_table "foos", force: :cascade do |t|
81
- t.datetime "bar", default: '1970-01-01 00:00:00', null: false
82
- end
83
- RUBY
84
- end
85
-
86
- it do
87
- delta = subject.diff(<<-RUBY)
88
- create_table "foos", force: :cascade do |t|
89
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
90
- end
91
- RUBY
92
-
93
- expect(delta.differ?).to be_truthy
94
- delta.migrate
95
-
96
- expect(subject.dump).to match_fuzzy <<-RUBY
97
- create_table "foos", force: :cascade do |t|
98
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
99
- end
100
- RUBY
101
- end
102
- end
103
-
104
- context 'when add column' do
105
- subject { client }
106
-
107
- before do
108
- subject.diff(<<-RUBY).migrate
109
- create_table "foos", force: :cascade do |t|
110
- t.integer "zoo"
111
- end
112
- RUBY
113
- end
114
-
115
- it do
116
- delta = subject.diff(<<-RUBY)
117
- create_table "foos", force: :cascade do |t|
118
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
119
- t.integer "zoo"
120
- end
121
- RUBY
122
-
123
- expect(delta.differ?).to be_truthy
124
- delta.migrate
125
-
126
- expect(subject.dump).to match_fuzzy <<-RUBY
127
- create_table "foos", force: :cascade do |t|
128
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
129
- t.integer "zoo"
130
- end
131
- RUBY
132
- end
133
- end
134
-
135
- context 'when drop column' do
136
- subject { client }
137
-
138
- before do
139
- subject.diff(<<-RUBY).migrate
140
- create_table "foos", force: :cascade do |t|
141
- t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
142
- t.integer "zoo"
143
- end
144
- RUBY
145
- end
146
-
147
- it do
148
- delta = subject.diff(<<-RUBY)
149
- create_table "foos", force: :cascade do |t|
150
- t.integer "zoo"
151
- end
152
- RUBY
153
-
154
- expect(delta.differ?).to be_truthy
155
- delta.migrate
156
-
157
- expect(subject.dump).to match_fuzzy <<-RUBY
158
- create_table "foos", force: :cascade do |t|
159
- t.integer "zoo"
160
- end
161
- RUBY
162
- end
163
- end
164
- end
@@ -1,189 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client.diff' do
4
- context 'when change column' do
5
- let(:tmpdir) { Dir.mktmpdir }
6
-
7
- let(:actual_dsl) do
8
- File.open("#{tmpdir}/file1.required", 'w') do |f|
9
- f.puts <<-RUBY
10
- create_table "clubs", force: :cascade do |t|
11
- t.string "name", default: "", null: false
12
- end
13
-
14
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
15
-
16
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
17
- t.string "dept_name", limit: 40, null: false
18
- end
19
-
20
- add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
21
-
22
- create_table "dept_emp", id: false, force: :cascade do |t|
23
- t.integer "emp_no", null: false
24
- t.string "dept_no", limit: 4, null: false
25
- t.date "from_date", null: false
26
- t.date "to_date", null: false
27
- end
28
-
29
- add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
30
- add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
31
-
32
- create_table "dept_manager", id: false, force: :cascade do |t|
33
- t.string "dept_no", limit: 4, null: false
34
- t.integer "emp_no", null: false
35
- t.date "from_date", null: false
36
- t.date "to_date", null: false
37
- end
38
-
39
- add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
40
- add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
41
- RUBY
42
- end
43
-
44
- f = File.open("#{tmpdir}/file1", 'w+')
45
-
46
- f.puts <<-RUBY
47
- require "file1.required"
48
-
49
- create_table "employee_clubs", force: :cascade do |t|
50
- t.integer "emp_no", null: false, unsigned: true
51
- t.integer "club_id", null: false, unsigned: true
52
- end
53
-
54
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
55
-
56
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
57
- t.date "birth_date", null: false
58
- t.string "first_name", limit: 14, null: false
59
- t.string "last_name", limit: 16, null: false
60
- t.string "gender", limit: 1, null: false
61
- t.date "hire_date", null: false
62
- end
63
-
64
- create_table "salaries", id: false, force: :cascade do |t|
65
- t.integer "emp_no", null: false
66
- t.integer "salary", null: false
67
- t.date "from_date", null: false
68
- t.date "to_date", null: false
69
- end
70
-
71
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
72
-
73
- create_table "titles", id: false, force: :cascade do |t|
74
- t.integer "emp_no", null: false
75
- t.string "title", limit: 50, null: false
76
- t.date "from_date", null: false
77
- t.date "to_date"
78
- end
79
-
80
- add_index "titles", ["emp_no"], name: "emp_no", using: :btree
81
- RUBY
82
-
83
- f.flush
84
- f.rewind
85
- f
86
- end
87
-
88
- let(:expected_dsl) do
89
- File.open("#{tmpdir}/file2.required", 'w') do |f|
90
- f.puts <<-RUBY
91
- create_table "clubs", force: :cascade do |t|
92
- t.string "name", default: "", null: false
93
- end
94
-
95
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
96
-
97
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
98
- t.string "dept_name", limit: 40, null: false
99
- end
100
-
101
- add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
102
-
103
- create_table "dept_emp", id: false, force: :cascade do |t|
104
- t.integer "emp_no", null: false
105
- t.string "dept_no", limit: 4, null: false
106
- t.date "from_date", null: false
107
- t.date "to_date", null: false
108
- end
109
-
110
- add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
111
- add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
112
-
113
- create_table "dept_manager", id: false, force: :cascade do |t|
114
- t.string "dept_no", limit: 4, null: false
115
- t.integer "emp_no", null: false
116
- t.date "from_date", null: false
117
- t.date "to_date", null: false
118
- end
119
-
120
- add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
121
- add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
122
- RUBY
123
- end
124
-
125
- f = File.open("#{tmpdir}/file2", 'w+')
126
-
127
- f.puts <<-RUBY
128
- require "file2.required"
129
-
130
- create_table "employee_clubs", force: :cascade do |t|
131
- t.integer "emp_no", unsigned: true, null: false
132
- t.integer "club_id", unsigned: false, null: true
133
- end
134
-
135
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
136
-
137
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
138
- t.date "birth_date", null: false
139
- t.string "first_name", limit: 14, null: false
140
- t.string "last_name", limit: 20, default: "XXX", null: false
141
- t.string "gender", limit: 2, null: false
142
- t.date "hire_date", null: false
143
- end
144
-
145
- create_table "salaries", id: false, force: :cascade do |t|
146
- t.integer "emp_no", null: false
147
- t.integer "salary", null: false
148
- t.date "from_date", null: false
149
- t.date "to_date", null: false
150
- end
151
-
152
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
153
-
154
- create_table "titles", id: false, force: :cascade do |t|
155
- t.integer "emp_no", null: false
156
- t.string "title", limit: 50, null: false
157
- t.date "from_date", null: false
158
- t.date "to_date"
159
- end
160
-
161
- add_index "titles", ["emp_no"], name: "emp_no", using: :btree
162
- RUBY
163
-
164
- f.flush
165
- f.rewind
166
- f
167
- end
168
-
169
- subject { Ridgepole::Client }
170
-
171
- # XXX: for AR 5.1
172
- before { client }
173
-
174
- it {
175
- delta = subject.diff(actual_dsl, expected_dsl)
176
- expect(delta.differ?).to be_truthy
177
- expect(delta.script).to match_ruby(<<-RUBY)
178
- change_column("employee_clubs", "club_id", :integer, **{:unsigned=>false, :null=>true, :default=>nil, :comment=>nil})
179
-
180
- change_column("employees", "last_name", :string, **{:limit=>20, :default=>"XXX", :unsigned=>false, :comment=>nil})
181
- change_column("employees", "gender", :string, **{:limit=>2, :null=>false, :default=>nil, :unsigned=>false, :comment=>nil})
182
- RUBY
183
- }
184
-
185
- after do
186
- FileUtils.remove_entry_secure(tmpdir)
187
- end
188
- end
189
- end