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,152 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when add column' 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", limit: 4, 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", 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: "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 "departments", primary_key: "dept_no", force: :cascade do |t|
75
- t.string "dept_name", limit: 40, null: false
76
- t.index ["dept_name"], name: "dept_name", unique: true
77
- end
78
-
79
- create_table "dept_emp", id: false, force: :cascade do |t|
80
- t.integer "emp_no", null: false
81
- t.string "dept_no", limit: 4, null: false
82
- t.date "from_date", null: false
83
- t.date "to_date", null: false
84
- t.index ["dept_no"], name: "dept_no"
85
- t.index ["emp_no"], name: "emp_no"
86
- end
87
-
88
- create_table "dept_manager", id: false, force: :cascade do |t|
89
- t.string "dept_no", limit: 4, null: false
90
- t.integer "emp_no", null: false
91
- t.date "from_date", null: false
92
- t.date "to_date", null: false
93
- t.index ["dept_no"], name: "dept_no"
94
- t.index ["emp_no"], name: "emp_no"
95
- end
96
-
97
- create_table "employee_clubs", force: :cascade do |t|
98
- t.integer "emp_no", null: false
99
- t.integer "club_id", null: false
100
- t.string "any_col", null: false
101
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
102
- end
103
-
104
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
105
- t.date "birth_date", null: false
106
- t.string "first_name", limit: 14, null: false
107
- t.string "last_name", limit: 16, null: false
108
- t.string "gender", limit: 1, null: false
109
- t.date "hire_date", null: false
110
- t.integer "age", null: false
111
- t.date "updated_at"
112
- end
113
-
114
- create_table "salaries", id: false, force: :cascade do |t|
115
- t.integer "emp_no", null: false
116
- t.integer "salary", null: false
117
- t.date "from_date", null: false
118
- t.date "to_date", null: false
119
- t.index ["emp_no"], name: "emp_no"
120
- end
121
-
122
- create_table "titles", id: false, force: :cascade do |t|
123
- t.integer "emp_no", null: false
124
- t.string "title", limit: 50, null: false
125
- t.date "from_date", null: false
126
- t.date "to_date"
127
- t.index ["emp_no"], name: "emp_no"
128
- end
129
- ERB
130
- end
131
-
132
- before { subject.diff(actual_dsl).migrate }
133
- subject { client }
134
-
135
- it {
136
- delta = subject.diff(expected_dsl)
137
- expect(delta.differ?).to be_truthy
138
- expect(subject.dump).to match_ruby actual_dsl
139
-
140
- script = <<-SHELL
141
- echo "$1" | #{MYSQL_CLI} #{TEST_SCHEMA}
142
- SHELL
143
-
144
- tempfile(File.basename(__FILE__), script) do |path|
145
- FileUtils.chmod(0o755, path)
146
- delta.migrate(external_script: path)
147
- end
148
-
149
- expect(subject.dump).to match_ruby expected_dsl
150
- }
151
- end
152
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change column (no change)' 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.index ["gender"], name: "gender"
14
- end
15
- ERB
16
- end
17
-
18
- let(:expected_dsl) do
19
- erbh(<<-ERB)
20
- create_table :employees, primary_key: :emp_no, force: :cascade do |t|
21
- t.date "birth_date", null: false
22
- t.string "first_name", limit: 14, null: false
23
- t.string "last_name", limit: 16, null: false
24
- t.string "gender", limit: 1, null: false
25
- t.date :hire_date, null: false
26
- t.index :gender, name: :gender
27
- end
28
- ERB
29
- end
30
-
31
- before { subject.diff(actual_dsl).migrate }
32
- subject { client }
33
-
34
- it {
35
- delta = subject.diff(expected_dsl)
36
- expect(delta.differ?).to be_falsey
37
- }
38
- end
39
-
40
- context 'when change column (change)' do
41
- let(:actual_dsl) do
42
- erbh(<<-ERB)
43
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
44
- t.date "birth_date", null: false
45
- t.string "first_name", limit: 14, null: false
46
- t.string "last_name", limit: 16, null: false
47
- t.string "gender", limit: 1, null: false
48
- t.date "hire_date", null: false
49
- t.index ["gender"], name: "gender"
50
- end
51
- ERB
52
- end
53
-
54
- let(:dsl) do
55
- erbh(<<-ERB)
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_date2, null: false
62
- t.index :last_name, name: :last_name
63
- end
64
- ERB
65
- end
66
-
67
- let(:expected_dsl) do
68
- erbh(<<-ERB)
69
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
70
- t.date "birth_date", null: false
71
- t.string "first_name", limit: 14, null: false
72
- t.string "last_name", limit: 16, null: false
73
- t.string "gender", limit: 1, null: false
74
- t.date "hire_date2", null: false
75
- t.index ["last_name"], name: "last_name"
76
- end
77
- ERB
78
- end
79
-
80
- before { subject.diff(actual_dsl).migrate }
81
- subject { client }
82
-
83
- it {
84
- delta = subject.diff(dsl)
85
- expect(delta.differ?).to be_truthy
86
- expect(subject.dump).to match_ruby actual_dsl
87
- delta.migrate
88
- expect(subject.dump).to match_ruby expected_dsl
89
- }
90
- end
91
- end
@@ -1,404 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when use timestamps (no change)' 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
- end
16
- RUBY
17
- end
18
-
19
- let(:expected_dsl) do
20
- <<-RUBY
21
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
22
- t.date "birth_date", null: false
23
- t.string "first_name", limit: 14, null: false
24
- t.string "last_name", limit: 16, null: false
25
- t.string "gender", limit: 1, null: false
26
- t.date "hire_date", null: false
27
- t.timestamps
28
- end
29
- RUBY
30
- end
31
-
32
- before { subject.diff(actual_dsl).migrate }
33
- subject { client }
34
-
35
- it {
36
- delta = subject.diff(expected_dsl)
37
- expect(delta.differ?).to be_falsey
38
- }
39
- end
40
-
41
- context 'when use timestamps (change)' do
42
- let(:actual_dsl) do
43
- erbh(<<-ERB)
44
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
45
- t.date "birth_date", null: false
46
- t.string "first_name", limit: 14, null: false
47
- t.string "last_name", limit: 16, null: false
48
- t.string "gender", limit: 1, null: false
49
- t.date "hire_date", null: false
50
- end
51
- ERB
52
- end
53
-
54
- let(:dsl) do
55
- <<-RUBY
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
- t.timestamps
63
- end
64
- RUBY
65
- end
66
-
67
- let(:expected_dsl) do
68
- erbh(<<-ERB)
69
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
70
- t.date "birth_date", null: false
71
- t.string "first_name", limit: 14, null: false
72
- t.string "last_name", limit: 16, null: false
73
- t.string "gender", limit: 1, null: false
74
- t.date "hire_date", null: false
75
- t.datetime "created_at", null: false
76
- t.datetime "updated_at", null: false
77
- end
78
- ERB
79
- end
80
-
81
- before { subject.diff(actual_dsl).migrate }
82
- subject { client }
83
-
84
- it {
85
- delta = subject.diff(dsl)
86
- expect(delta.differ?).to be_truthy
87
- expect(subject.dump).to match_ruby actual_dsl
88
- delta.migrate
89
- expect(subject.dump).to match_ruby expected_dsl
90
- }
91
- end
92
-
93
- context 'when use references (no change)' do
94
- let(:actual_dsl) do
95
- erbh(<<-ERB)
96
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
97
- t.date "birth_date", null: false
98
- t.string "first_name", limit: 14, null: false
99
- t.string "last_name", limit: 16, null: false
100
- t.string "gender", limit: 1, null: false
101
- t.date "hire_date", null: false
102
- t.bigint "user_id"
103
- t.index "user_id"
104
- end
105
- ERB
106
- end
107
-
108
- let(:expected_dsl) do
109
- <<-RUBY
110
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
111
- t.date "birth_date", null: false
112
- t.string "first_name", limit: 14, null: false
113
- t.string "last_name", limit: 16, null: false
114
- t.string "gender", limit: 1, null: false
115
- t.date "hire_date", null: false
116
- t.references :user
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
-
130
- context 'when use references with polymorphic (no change)' do
131
- let(:actual_dsl) do
132
- erbh(<<-ERB)
133
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
134
- t.date "birth_date", null: false
135
- t.string "first_name", limit: 14, null: false
136
- t.string "last_name", limit: 16, null: false
137
- t.string "gender", limit: 1, null: false
138
- t.date "hire_date", null: false
139
- t.bigint "user_id"
140
- t.string "user_type"
141
- t.index ["user_type", "user_id"]
142
- end
143
- ERB
144
- end
145
-
146
- let(:expected_dsl) do
147
- <<-RUBY
148
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
149
- t.date "birth_date", null: false
150
- t.string "first_name", limit: 14, null: false
151
- t.string "last_name", limit: 16, null: false
152
- t.string "gender", limit: 1, null: false
153
- t.date "hire_date", null: false
154
- t.references :user, polymorphic: true
155
- end
156
- RUBY
157
- end
158
-
159
- before { subject.diff(actual_dsl).migrate }
160
- subject { client }
161
-
162
- it {
163
- delta = subject.diff(expected_dsl)
164
- expect(delta.differ?).to be_falsey
165
- }
166
- end
167
-
168
- context 'when use references with unsigned polymorphic (no change)' do
169
- let(:actual_dsl) do
170
- erbh(<<-ERB)
171
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
172
- t.bigint "user_id", unsigned: true
173
- t.string "user_type"
174
- t.index ["user_type", "user_id"]
175
- end
176
- ERB
177
- end
178
-
179
- let(:expected_dsl) do
180
- <<-RUBY
181
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
182
- t.references :user, unsigned: true, polymorphic: true
183
- end
184
- RUBY
185
- end
186
-
187
- before { subject.diff(actual_dsl).migrate }
188
- subject { client }
189
-
190
- it {
191
- delta = subject.diff(expected_dsl)
192
- expect(delta.differ?).to be_falsey
193
- }
194
- end
195
-
196
- context 'when use references (change)' do
197
- let(:actual_dsl) do
198
- erbh(<<-ERB)
199
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
200
- t.date "birth_date", null: false
201
- t.string "first_name", limit: 14, null: false
202
- t.string "last_name", limit: 16, null: false
203
- t.string "gender", limit: 1, null: false
204
- t.date "hire_date", null: false
205
- end
206
- ERB
207
- end
208
-
209
- let(:dsl) do
210
- <<-RUBY
211
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
212
- t.date "birth_date", null: false
213
- t.string "first_name", limit: 14, null: false
214
- t.string "last_name", limit: 16, null: false
215
- t.string "gender", limit: 1, null: false
216
- t.date "hire_date", null: false
217
- t.references :user
218
- end
219
- RUBY
220
- end
221
-
222
- let(:expected_dsl) do
223
- erbh(<<-ERB)
224
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
225
- t.date "birth_date", null: false
226
- t.string "first_name", limit: 14, null: false
227
- t.string "last_name", limit: 16, null: false
228
- t.string "gender", limit: 1, null: false
229
- t.date "hire_date", null: false
230
- t.bigint "user_id"
231
- t.index ["user_id"], name: "index_employees_on_user_id"
232
- end
233
- ERB
234
- end
235
-
236
- before { subject.diff(actual_dsl).migrate }
237
- subject { client }
238
-
239
- it {
240
- delta = subject.diff(dsl)
241
- expect(delta.differ?).to be_truthy
242
- expect(subject.dump).to match_ruby actual_dsl
243
- delta.migrate
244
- expect(subject.dump).to match_ruby expected_dsl
245
- }
246
- end
247
-
248
- context 'when use references with polymorphic (change)' do
249
- let(:actual_dsl) do
250
- erbh(<<-ERB)
251
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
252
- t.date "birth_date", null: false
253
- t.string "first_name", limit: 14, null: false
254
- t.string "last_name", limit: 16, null: false
255
- t.string "gender", limit: 1, null: false
256
- t.date "hire_date", null: false
257
- end
258
- ERB
259
- end
260
-
261
- let(:dsl) do
262
- <<-RUBY
263
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
264
- t.date "birth_date", null: false
265
- t.string "first_name", limit: 14, null: false
266
- t.string "last_name", limit: 16, null: false
267
- t.string "gender", limit: 1, null: false
268
- t.date "hire_date", null: false
269
- t.references :user, polymorphic: true
270
- end
271
- RUBY
272
- end
273
-
274
- let(:expected_dsl) do
275
- erbh(<<-ERB)
276
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
277
- t.date "birth_date", null: false
278
- t.string "first_name", limit: 14, null: false
279
- t.string "last_name", limit: 16, null: false
280
- t.string "gender", limit: 1, null: false
281
- t.date "hire_date", null: false
282
- t.bigint "user_id"
283
- t.string "user_type"
284
- t.index ["user_type", "user_id"], name: "index_employees_on_user_type_and_user_id"
285
- end
286
- ERB
287
- end
288
-
289
- before { subject.diff(actual_dsl).migrate }
290
- subject { client }
291
-
292
- it {
293
- delta = subject.diff(dsl)
294
- expect(delta.differ?).to be_truthy
295
- expect(subject.dump).to match_ruby actual_dsl
296
- delta.migrate
297
- expect(subject.dump).to match_ruby expected_dsl
298
- }
299
- end
300
-
301
- context 'when use references with fk (no change)' do
302
- let(:actual_dsl) do
303
- erbh(<<-ERB)
304
- create_table "users", force: :cascade do |t|
305
- end
306
-
307
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
308
- t.date "birth_date", null: false
309
- t.string "first_name", limit: 14, null: false
310
- t.string "last_name", limit: 16, null: false
311
- t.string "gender", limit: 1, null: false
312
- t.date "hire_date", null: false
313
- t.bigint "user_id"
314
- t.index "user_id"
315
- end
316
-
317
- add_foreign_key("employees", "users")
318
- ERB
319
- end
320
-
321
- let(:expected_dsl) do
322
- erbh(<<-ERB)
323
- create_table "users", force: :cascade do |t|
324
- end
325
-
326
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
327
- t.date "birth_date", null: false
328
- t.string "first_name", limit: 14, null: false
329
- t.string "last_name", limit: 16, null: false
330
- t.string "gender", limit: 1, null: false
331
- t.date "hire_date", null: false
332
- t.references :user, foreign_key: true
333
- end
334
- ERB
335
- end
336
-
337
- before { subject.diff(actual_dsl).migrate }
338
- subject { client }
339
-
340
- it {
341
- delta = subject.diff(expected_dsl)
342
- expect(delta.differ?).to be_falsey
343
- }
344
- end
345
-
346
- context 'when use references with fk (change)' do
347
- let(:actual_dsl) do
348
- erbh(<<-ERB)
349
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
350
- t.date "birth_date", null: false
351
- t.string "first_name", limit: 14, null: false
352
- t.string "last_name", limit: 16, null: false
353
- t.string "gender", limit: 1, null: false
354
- t.date "hire_date", null: false
355
- end
356
- create_table "users", force: :cascade do |t|
357
- end
358
- ERB
359
- end
360
-
361
- let(:dsl) do
362
- erbh(<<-ERB)
363
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
364
- t.date "birth_date", null: false
365
- t.string "first_name", limit: 14, null: false
366
- t.string "last_name", limit: 16, null: false
367
- t.string "gender", limit: 1, null: false
368
- t.date "hire_date", null: false
369
- t.references :user, foreign_key: true
370
- end
371
- create_table "users", force: :cascade do |t|
372
- end
373
- ERB
374
- end
375
-
376
- let(:expected_dsl) do
377
- erbh(<<-ERB)
378
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
379
- t.date "birth_date", null: false
380
- t.string "first_name", limit: 14, null: false
381
- t.string "last_name", limit: 16, null: false
382
- t.string "gender", limit: 1, null: false
383
- t.date "hire_date", null: false
384
- t.bigint "user_id"
385
- t.index ["user_id"], name: "index_employees_on_user_id"
386
- end
387
- create_table "users", force: :cascade do |t|
388
- end
389
- add_foreign_key("employees", "users")
390
- ERB
391
- end
392
-
393
- before { subject.diff(actual_dsl).migrate }
394
- subject { client }
395
-
396
- it {
397
- delta = subject.diff(dsl)
398
- expect(delta.differ?).to be_truthy
399
- expect(subject.dump).to match_ruby actual_dsl
400
- delta.migrate
401
- expect(subject.dump).to match_ruby expected_dsl
402
- }
403
- end
404
- end