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,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change column (boolean without limit)' do
5
- let(:actual_dsl) do
6
- <<-RUBY
7
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
8
- t.date "birth_date", null: false
9
- t.string "first_name", limit: 14, null: false
10
- t.string "last_name", limit: 16, null: false
11
- t.string "gender", limit: 1, null: false
12
- t.date "hire_date", null: false
13
- t.datetime "created_at", null: false
14
- t.datetime "updated_at", null: false
15
- t.boolean "registered"
16
- end
17
- RUBY
18
- end
19
-
20
- let(:expected_dsl) do
21
- <<-RUBY
22
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
23
- t.date "birth_date", null: false
24
- t.string "first_name", limit: 14, null: false
25
- t.string "last_name", limit: 16, null: false
26
- t.string "gender", limit: 1, null: false
27
- t.date "hire_date", null: false
28
- t.datetime "created_at", null: false
29
- t.datetime "updated_at", null: false
30
- t.boolean "registered"
31
- end
32
- RUBY
33
- end
34
-
35
- before { subject.diff(actual_dsl).migrate }
36
- subject { client }
37
-
38
- it {
39
- delta = subject.diff(expected_dsl)
40
- expect(delta.differ?).to be_falsey
41
- }
42
- end
43
-
44
- context 'when change column (boolean with limit)' do
45
- let(:actual_dsl) do
46
- <<-RUBY
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
- t.datetime "created_at", null: false
54
- t.datetime "updated_at", null: false
55
- t.boolean "registered"
56
- end
57
- RUBY
58
- end
59
-
60
- let(:expected_dsl) do
61
- <<-RUBY
62
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
63
- t.date "birth_date", null: false
64
- t.string "first_name", limit: 14, null: false
65
- t.string "last_name", limit: 16, null: false
66
- t.string "gender", limit: 1, null: false
67
- t.date "hire_date", null: false
68
- t.datetime "created_at", null: false
69
- t.datetime "updated_at", null: false
70
- t.boolean "registered", limit: 1
71
- end
72
- RUBY
73
- end
74
-
75
- before { subject.diff(actual_dsl).migrate }
76
- subject { client }
77
-
78
- it {
79
- delta = subject.diff(expected_dsl)
80
- expect(delta.differ?).to be_falsey
81
- }
82
- end
83
- end
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change column (binary: blob -> varbinary)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
8
- t.date "birth_date", null: false
9
- t.string "first_name", limit: 14, null: false
10
- t.string "last_name", limit: 16, null: false
11
- t.string "gender", limit: 1, null: false
12
- t.date "hire_date", null: false
13
- t.datetime "created_at", null: false
14
- t.datetime "updated_at", null: false
15
- t.binary "registered_name"
16
- end
17
- ERB
18
- end
19
-
20
- let(:expected_dsl) do
21
- erbh(<<-ERB)
22
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
23
- t.date "birth_date", null: false
24
- t.string "first_name", limit: 14, null: false
25
- t.string "last_name", limit: 16, null: false
26
- t.string "gender", limit: 1, null: false
27
- t.date "hire_date", null: false
28
- t.datetime "created_at", null: false
29
- t.datetime "updated_at", null: false
30
- t.binary "registered_name", limit: 255
31
- end
32
- ERB
33
- end
34
-
35
- before { subject.diff(actual_dsl).migrate }
36
- subject { client }
37
-
38
- it {
39
- delta = subject.diff(expected_dsl)
40
- expect(delta.differ?).to be_truthy
41
- expect(subject.dump).to match_ruby actual_dsl
42
- delta.migrate
43
- expect(subject.dump).to match_ruby expected_dsl
44
- }
45
- end
46
-
47
- context 'when change column (binary: varbinary -> blob)' do
48
- let(:actual_dsl) do
49
- erbh(<<-ERB)
50
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
51
- t.date "birth_date", null: false
52
- t.string "first_name", limit: 14, null: false
53
- t.string "last_name", limit: 16, null: false
54
- t.string "gender", limit: 1, null: false
55
- t.date "hire_date", null: false
56
- t.datetime "created_at", null: false
57
- t.datetime "updated_at", null: false
58
- t.binary "registered_name", limit: 255
59
- end
60
- ERB
61
- end
62
-
63
- let(:expected_dsl) do
64
- erbh(<<-ERB)
65
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
66
- t.date "birth_date", null: false
67
- t.string "first_name", limit: 14, null: false
68
- t.string "last_name", limit: 16, null: false
69
- t.string "gender", limit: 1, null: false
70
- t.date "hire_date", null: false
71
- t.datetime "created_at", null: false
72
- t.datetime "updated_at", null: false
73
- t.binary "registered_name"
74
- end
75
- ERB
76
- end
77
-
78
- before { subject.diff(actual_dsl).migrate }
79
- subject { client }
80
-
81
- it {
82
- delta = subject.diff(expected_dsl)
83
- expect(delta.differ?).to be_truthy
84
- expect(subject.dump).to match_ruby actual_dsl
85
- delta.migrate
86
- expect(subject.dump).to match_ruby expected_dsl
87
- }
88
- end
89
-
90
- context 'when change column (binary without limit)' do
91
- let(:actual_dsl) do
92
- erbh(<<-ERB)
93
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
94
- t.date "birth_date", null: false
95
- t.string "first_name", limit: 14, null: false
96
- t.string "last_name", limit: 16, null: false
97
- t.string "gender", limit: 1, null: false
98
- t.date "hire_date", null: false
99
- t.datetime "created_at", null: false
100
- t.datetime "updated_at", null: false
101
- t.binary "registered_name"
102
- end
103
- ERB
104
- end
105
-
106
- let(:expected_dsl) do
107
- <<-RUBY
108
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
109
- t.date "birth_date", null: false
110
- t.string "first_name", limit: 14, null: false
111
- t.string "last_name", limit: 16, null: false
112
- t.string "gender", limit: 1, null: false
113
- t.date "hire_date", null: false
114
- t.datetime "created_at", null: false
115
- t.datetime "updated_at", null: false
116
- t.binary "registered_name"
117
- end
118
- RUBY
119
- end
120
-
121
- before { subject.diff(actual_dsl).migrate }
122
- subject { client }
123
-
124
- it {
125
- delta = subject.diff(expected_dsl)
126
- expect(delta.differ?).to be_falsey
127
- }
128
- end
129
- end
@@ -1,241 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when add column after id (pk: normal)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "employees", force: :cascade do |t|
8
- t.date "birth_date", null: false
9
- t.string "first_name", limit: 14, null: false
10
- t.string "last_name", limit: 16, null: false
11
- t.string "gender", limit: 1, null: false
12
- t.date "hire_date", null: false
13
- t.datetime "created_at", null: false
14
- t.datetime "updated_at", null: false
15
- t.binary "registered_name"
16
- end
17
- ERB
18
- end
19
-
20
- let(:expected_dsl) do
21
- erbh(<<-ERB)
22
- create_table "employees", force: :cascade do |t|
23
- t.string "ext_column", null: false
24
- t.date "birth_date", null: false
25
- t.string "first_name", limit: 14, null: false
26
- t.string "last_name", limit: 16, null: false
27
- t.string "gender", limit: 1, null: false
28
- t.date "hire_date", null: false
29
- t.datetime "created_at", null: false
30
- t.datetime "updated_at", null: false
31
- t.binary "registered_name", limit: 255
32
- end
33
- ERB
34
- end
35
-
36
- before { subject.diff(actual_dsl).migrate }
37
- subject { client }
38
-
39
- it {
40
- delta = subject.diff(expected_dsl)
41
- expect(delta.differ?).to be_truthy
42
- expect(subject.dump).to match_ruby actual_dsl
43
- delta.migrate
44
- expect(subject.dump).to match_ruby expected_dsl
45
-
46
- expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
47
- CREATE TABLE `employees` (
48
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
49
- `ext_column` varchar(255) NOT NULL,
50
- `birth_date` date NOT NULL,
51
- `first_name` varchar(14) NOT NULL,
52
- `last_name` varchar(16) NOT NULL,
53
- `gender` varchar(1) NOT NULL,
54
- `hire_date` date NOT NULL,
55
- `created_at` datetime NOT NULL,
56
- `updated_at` datetime NOT NULL,
57
- `registered_name` varbinary(255) DEFAULT NULL,
58
- PRIMARY KEY (`id`)
59
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
60
- ERB
61
- }
62
- end
63
-
64
- context 'when add column after id (pk: emp_id)' do
65
- let(:actual_dsl) do
66
- erbh(<<-ERB)
67
- create_table "employees", primary_key: "emp_id", force: :cascade do |t|
68
- t.date "birth_date", null: false
69
- t.string "first_name", limit: 14, null: false
70
- t.string "last_name", limit: 16, null: false
71
- t.string "gender", limit: 1, null: false
72
- t.date "hire_date", null: false
73
- t.datetime "created_at", null: false
74
- t.datetime "updated_at", null: false
75
- t.binary "registered_name"
76
- end
77
- ERB
78
- end
79
-
80
- let(:expected_dsl) do
81
- erbh(<<-ERB)
82
- create_table "employees", primary_key: "emp_id", force: :cascade do |t|
83
- t.string "ext_column", null: false
84
- t.date "birth_date", null: false
85
- t.string "first_name", limit: 14, null: false
86
- t.string "last_name", limit: 16, null: false
87
- t.string "gender", limit: 1, null: false
88
- t.date "hire_date", null: false
89
- t.datetime "created_at", null: false
90
- t.datetime "updated_at", null: false
91
- t.binary "registered_name", limit: 255
92
- end
93
- ERB
94
- end
95
-
96
- before { subject.diff(actual_dsl).migrate }
97
- subject { client }
98
-
99
- it {
100
- delta = subject.diff(expected_dsl)
101
- expect(delta.differ?).to be_truthy
102
- expect(subject.dump).to match_ruby actual_dsl
103
- delta.migrate
104
- expect(subject.dump).to match_ruby expected_dsl
105
-
106
- expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
107
- CREATE TABLE `employees` (
108
- `emp_id` bigint(20) NOT NULL AUTO_INCREMENT,
109
- `ext_column` varchar(255) NOT NULL,
110
- `birth_date` date NOT NULL,
111
- `first_name` varchar(14) NOT NULL,
112
- `last_name` varchar(16) NOT NULL,
113
- `gender` varchar(1) NOT NULL,
114
- `hire_date` date NOT NULL,
115
- `created_at` datetime NOT NULL,
116
- `updated_at` datetime NOT NULL,
117
- `registered_name` varbinary(255) DEFAULT NULL,
118
- PRIMARY KEY (`emp_id`)
119
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
120
- ERB
121
- }
122
- end
123
-
124
- context 'when add column after id (pk: no pk)' do
125
- let(:actual_dsl) do
126
- erbh(<<-ERB)
127
- create_table "employees", id: false, force: :cascade do |t|
128
- t.date "birth_date", null: false
129
- t.string "first_name", limit: 14, null: false
130
- t.string "last_name", limit: 16, null: false
131
- t.string "gender", limit: 1, null: false
132
- t.date "hire_date", null: false
133
- t.datetime "created_at", null: false
134
- t.datetime "updated_at", null: false
135
- t.binary "registered_name"
136
- end
137
- ERB
138
- end
139
-
140
- let(:expected_dsl) do
141
- erbh(<<-ERB)
142
- create_table "employees", id: false, force: :cascade do |t|
143
- t.string "ext_column", null: false
144
- t.date "birth_date", null: false
145
- t.string "first_name", limit: 14, null: false
146
- t.string "last_name", limit: 16, null: false
147
- t.string "gender", limit: 1, null: false
148
- t.date "hire_date", null: false
149
- t.datetime "created_at", null: false
150
- t.datetime "updated_at", null: false
151
- t.binary "registered_name", limit: 255
152
- end
153
- ERB
154
- end
155
-
156
- before { subject.diff(actual_dsl).migrate }
157
- subject { client }
158
-
159
- it {
160
- delta = subject.diff(expected_dsl)
161
- expect(delta.differ?).to be_truthy
162
- expect(subject.dump).to match_ruby actual_dsl
163
- delta.migrate
164
- expect(subject.dump).to match_ruby expected_dsl
165
-
166
- expect(show_create_table_mysql('employees')).to match_fuzzy <<-SQL
167
- CREATE TABLE `employees` (
168
- `ext_column` varchar(255) NOT NULL,
169
- `birth_date` date NOT NULL,
170
- `first_name` varchar(14) NOT NULL,
171
- `last_name` varchar(16) NOT NULL,
172
- `gender` varchar(1) NOT NULL,
173
- `hire_date` date NOT NULL,
174
- `created_at` datetime NOT NULL,
175
- `updated_at` datetime NOT NULL,
176
- `registered_name` varbinary(255) DEFAULT NULL
177
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
178
- SQL
179
- }
180
- end
181
-
182
- context 'when add column after id (pk: with pk delta)' do
183
- let(:actual_dsl) do
184
- erbh(<<-ERB)
185
- create_table "employees", force: :cascade do |t|
186
- t.date "birth_date", null: false
187
- t.string "first_name", limit: 14, null: false
188
- t.string "last_name", limit: 16, null: false
189
- t.string "gender", limit: 1, null: false
190
- t.date "hire_date", null: false
191
- t.datetime "created_at", null: false
192
- t.datetime "updated_at", null: false
193
- t.binary "registered_name"
194
- end
195
- ERB
196
- end
197
-
198
- let(:expected_dsl) do
199
- erbh(<<-ERB)
200
- create_table "employees", primary_key: "emp_id", force: :cascade do |t|
201
- t.string "ext_column", null: false
202
- t.date "birth_date", null: false
203
- t.string "first_name", limit: 14, null: false
204
- t.string "last_name", limit: 16, null: false
205
- t.string "gender", limit: 1, null: false
206
- t.date "hire_date", null: false
207
- t.datetime "created_at", null: false
208
- t.datetime "updated_at", null: false
209
- t.binary "registered_name", limit: 255
210
- end
211
- ERB
212
- end
213
-
214
- before { subject.diff(actual_dsl).migrate }
215
- subject { client }
216
-
217
- it {
218
- delta = subject.diff(expected_dsl)
219
- expect(delta.differ?).to be_truthy
220
- expect(subject.dump).to match_ruby actual_dsl
221
- delta.migrate
222
- expect(subject.dump).to match_ruby expected_dsl.sub(/, *primary_key: *"emp_id"/, '')
223
-
224
- expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
225
- CREATE TABLE `employees` (
226
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
227
- `ext_column` varchar(255) NOT NULL,
228
- `birth_date` date NOT NULL,
229
- `first_name` varchar(14) NOT NULL,
230
- `last_name` varchar(16) NOT NULL,
231
- `gender` varchar(1) NOT NULL,
232
- `hire_date` date NOT NULL,
233
- `created_at` datetime NOT NULL,
234
- `updated_at` datetime NOT NULL,
235
- `registered_name` varbinary(255) DEFAULT NULL,
236
- PRIMARY KEY (`id`)
237
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
238
- ERB
239
- }
240
- end
241
- end