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,168 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client.diff' do
4
- context 'when change column' do
5
- let(:actual_dsl) do
6
- <<-RUBY
7
- create_table "clubs", force: :cascade do |t|
8
- t.string "name", default: "", null: false
9
- end
10
-
11
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
12
-
13
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
14
- t.string "dept_name", limit: 40, null: false
15
- end
16
-
17
- add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
18
-
19
- create_table "dept_emp", id: false, force: :cascade do |t|
20
- t.integer "emp_no", null: false
21
- t.string "dept_no", limit: 4, null: false
22
- t.date "from_date", null: false
23
- t.date "to_date", null: false
24
- end
25
-
26
- add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
27
- add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
28
-
29
- create_table "dept_manager", id: false, force: :cascade do |t|
30
- t.string "dept_no", limit: 4, null: false
31
- t.integer "emp_no", null: false
32
- t.date "from_date", null: false
33
- t.date "to_date", null: false
34
- end
35
-
36
- add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
37
- add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
38
-
39
- create_table "employee_clubs", force: :cascade do |t|
40
- t.integer "emp_no", null: false, unsigned: true
41
- t.integer "club_id", null: false, unsigned: true
42
- end
43
-
44
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
45
-
46
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
47
- t.date "birth_date", null: false
48
- t.string "first_name", limit: 14, null: false
49
- t.string "last_name", limit: 16, null: false
50
- t.string "gender", limit: 1, null: false
51
- t.date "hire_date", null: false
52
- end
53
-
54
- create_table "salaries", id: false, force: :cascade do |t|
55
- t.integer "emp_no", null: false
56
- t.integer "salary", null: false
57
- t.date "from_date", null: false
58
- t.date "to_date", null: false
59
- end
60
-
61
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
62
-
63
- create_table "titles", id: false, force: :cascade do |t|
64
- t.integer "emp_no", null: false
65
- t.string "title", limit: 50, null: false
66
- t.date "from_date", null: false
67
- t.date "to_date"
68
- end
69
-
70
- add_index "titles", ["emp_no"], name: "emp_no", using: :btree
71
- RUBY
72
- end
73
-
74
- let(:expected_dsl) do
75
- <<-RUBY
76
- create_table "clubs", force: :cascade do |t|
77
- t.string "name", default: "", null: false
78
- end
79
-
80
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
81
-
82
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
83
- t.string "dept_name", limit: 40, null: false
84
- end
85
-
86
- add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
87
-
88
- create_table "dept_emp", id: false, force: :cascade do |t|
89
- t.integer "emp_no", null: false
90
- t.string "dept_no", limit: 4, null: false
91
- t.date "from_date", null: false
92
- t.date "to_date", null: false
93
- end
94
-
95
- add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
96
- add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
97
-
98
- create_table "dept_manager", id: false, force: :cascade do |t|
99
- t.string "dept_no", limit: 4, null: false
100
- t.integer "emp_no", null: false
101
- t.date "from_date", null: false
102
- t.date "to_date", null: false
103
- end
104
-
105
- add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
106
- add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
107
-
108
- create_table "employee_clubs", force: :cascade do |t|
109
- t.integer "emp_no", unsigned: true, null: false
110
- t.integer "club_id", unsigned: false, null: true
111
- end
112
-
113
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
114
-
115
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
116
- t.date "birth_date", null: false
117
- t.string "first_name", limit: 14, null: false
118
- t.string "last_name", limit: 20, default: "XXX", null: false
119
- t.string "gender", limit: 2, null: false
120
- t.date "hire_date", null: false
121
- end
122
-
123
- create_table "salaries", id: false, force: :cascade do |t|
124
- t.integer "emp_no", null: false
125
- t.integer "salary", null: false
126
- t.date "from_date", null: false
127
- t.date "to_date", null: false
128
- end
129
-
130
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
131
-
132
- create_table "titles", id: false, force: :cascade do |t|
133
- t.integer "emp_no", null: false
134
- t.string "title", limit: 50, null: false
135
- t.date "from_date", null: false
136
- t.date "to_date"
137
- end
138
-
139
- add_index "titles", ["emp_no"], name: "emp_no", using: :btree
140
- RUBY
141
- end
142
-
143
- subject { Ridgepole::Client }
144
-
145
- # XXX: for AR 5.1
146
- before { client }
147
-
148
- it {
149
- delta = subject.diff(actual_dsl, expected_dsl)
150
- expect(delta.differ?).to be_truthy
151
- expect(delta.script).to match_ruby erbh(<<-ERB)
152
- change_column("employee_clubs", "club_id", :integer, **{:unsigned=>false, :null=>true, :default=>nil, :comment=>nil})
153
-
154
- change_column("employees", "last_name", :string, **{:limit=>20, :default=>"XXX", :unsigned=>false, :comment=>nil})
155
- change_column("employees", "gender", :string, **{:limit=>2, :null=>false, :default=>nil, :unsigned=>false, :comment=>nil})
156
- ERB
157
- }
158
- end
159
-
160
- context 'without the target table' do
161
- subject { Ridgepole::Client }
162
-
163
- it {
164
- expect(Ridgepole::Logger.instance).to receive(:warn).with(/definition is not found/)
165
- subject.diff('', '', tables: %w[some_table_name])
166
- }
167
- end
168
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client.dump' do
4
- context 'when there is a tables' do
5
- before { restore_tables }
6
- subject { Ridgepole::Client }
7
-
8
- it {
9
- expect(subject.dump(conn_spec, dump_without_table_options: true)).to match_fuzzy erbh(<<-ERB)
10
- create_table "clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true } }) %>, force: :cascade do |t|
11
- t.string "name", default: "", null: false
12
- t.index ["name"], name: "idx_name", unique: true
13
- end
14
-
15
- create_table "departments", primary_key: "dept_no", <%= i cond(">= 6.1", { id: { type: :string, limit: 4 } }, { id: :string, limit: 4 }) %>, force: :cascade do |t|
16
- t.string "dept_name", limit: 40, null: false
17
- t.index ["dept_name"], name: "dept_name", unique: true
18
- end
19
-
20
- create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
21
- t.integer "emp_no", null: false
22
- t.string "dept_no", limit: 4, null: false
23
- t.date "from_date", null: false
24
- t.date "to_date", null: false
25
- t.index ["dept_no"], name: "dept_no"
26
- t.index ["emp_no"], name: "emp_no"
27
- end
28
-
29
- create_table "dept_manager", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
30
- t.string "dept_no", limit: 4, null: false
31
- t.integer "emp_no", null: false
32
- t.date "from_date", null: false
33
- t.date "to_date", null: false
34
- t.index ["dept_no"], name: "dept_no"
35
- t.index ["emp_no"], name: "emp_no"
36
- end
37
-
38
- create_table "employee_clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true }}) %>, force: :cascade do |t|
39
- t.integer "emp_no", null: false, unsigned: true
40
- t.integer "club_id", null: false, unsigned: true
41
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
42
- end
43
-
44
- create_table "employees", primary_key: "emp_no", id: :integer, default: nil, 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
- <%- if condition('< 6.0.0.beta2') -%>
49
- t.string "gender", limit: 1, null: false
50
- <%- else -%>
51
- t.column "gender", "enum('M','F')", null: false
52
- <%- end -%>
53
- t.date "hire_date", null: false
54
- end
55
-
56
- create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
57
- t.integer "emp_no", null: false
58
- t.integer "salary", null: false
59
- t.date "from_date", null: false
60
- t.date "to_date", null: false
61
- t.index ["emp_no"], name: "emp_no"
62
- end
63
-
64
- create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
65
- t.integer "emp_no", null: false
66
- t.string "title", limit: 50, null: false
67
- t.date "from_date", null: false
68
- t.date "to_date"
69
- t.index ["emp_no"], name: "emp_no"
70
- end
71
- ERB
72
- }
73
- end
74
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#dump' do
4
- context 'when there is a tables (dump some tables)' do
5
- before { restore_tables }
6
- subject { client(tables: %w[employees salaries]) }
7
-
8
- it {
9
- expect(subject.dump).to match_fuzzy erbh(<<-ERB)
10
- create_table "employees", primary_key: "emp_no", id: :integer, default: nil, force: :cascade do |t|
11
- t.date "birth_date", null: false
12
- t.string "first_name", limit: 14, null: false
13
- t.string "last_name", limit: 16, null: false
14
- <%- if condition('< 6.0.0.beta2') -%>
15
- t.string "gender", limit: 1, null: false
16
- <%- else -%>
17
- t.column "gender", "enum('M','F')", null: false
18
- <%- end -%>
19
- t.date "hire_date", null: false
20
- end
21
-
22
- create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
23
- t.integer "emp_no", null: false
24
- t.integer "salary", null: false
25
- t.date "from_date", null: false
26
- t.date "to_date", null: false
27
- t.index ["emp_no"], name: "emp_no"
28
- end
29
- ERB
30
- }
31
- end
32
-
33
- context 'when there is a tables (use ignore table)' do
34
- before { restore_tables }
35
- subject do
36
- client(ignore_tables: [
37
- /^clubs$/,
38
- /^departments$/,
39
- /^dept_emp$/,
40
- /^dept_manager$/,
41
- /^employee_clubs$/,
42
- /^titles$/
43
- ])
44
- end
45
-
46
- it {
47
- expect(subject.dump).to match_fuzzy erbh(<<-ERB)
48
- create_table "employees", primary_key: "emp_no", id: :integer, default: nil, force: :cascade do |t|
49
- t.date "birth_date", null: false
50
- t.string "first_name", limit: 14, null: false
51
- t.string "last_name", limit: 16, null: false
52
- <%- if condition('< 6.0.0.beta2') -%>
53
- t.string "gender", limit: 1, null: false
54
- <%- else -%>
55
- t.column "gender", "enum('M','F')", null: false
56
- <%- end -%>
57
- t.date "hire_date", null: false
58
- end
59
-
60
- create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
61
- t.integer "emp_no", null: false
62
- t.integer "salary", null: false
63
- t.date "from_date", null: false
64
- t.date "to_date", null: false
65
- t.index ["emp_no"], name: "emp_no"
66
- end
67
- ERB
68
- }
69
- end
70
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#dump' do
4
- context 'when there is a tables' do
5
- before { restore_tables }
6
- subject { client }
7
-
8
- it {
9
- expect(subject.dump).to match_fuzzy erbh(<<-ERB)
10
- create_table "clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true } }) %>, force: :cascade do |t|
11
- t.string "name", default: "", null: false
12
- t.index ["name"], name: "idx_name", unique: true
13
- end
14
-
15
- create_table "departments", primary_key: "dept_no", <%= i cond(">= 6.1", { id: { type: :string, limit: 4 } }, { id: :string, limit: 4 }) %>, force: :cascade do |t|
16
- t.string "dept_name", limit: 40, null: false
17
- t.index ["dept_name"], name: "dept_name", unique: true
18
- end
19
-
20
- create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
21
- t.integer "emp_no", null: false
22
- t.string "dept_no", limit: 4, null: false
23
- t.date "from_date", null: false
24
- t.date "to_date", null: false
25
- t.index ["dept_no"], name: "dept_no"
26
- t.index ["emp_no"], name: "emp_no"
27
- end
28
-
29
- create_table "dept_manager", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
30
- t.string "dept_no", limit: 4, null: false
31
- t.integer "emp_no", null: false
32
- t.date "from_date", null: false
33
- t.date "to_date", null: false
34
- t.index ["dept_no"], name: "dept_no"
35
- t.index ["emp_no"], name: "emp_no"
36
- end
37
-
38
- create_table "employee_clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true } }) %>, force: :cascade do |t|
39
- t.integer "emp_no", null: false, unsigned: true
40
- t.integer "club_id", null: false, unsigned: true
41
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
42
- end
43
-
44
- create_table "employees", primary_key: "emp_no", id: :integer, default: nil, 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
- <%- if condition('< 6.0.0.beta2') -%>
49
- t.string "gender", limit: 1, null: false
50
- <%- else -%>
51
- t.column "gender", "enum('M','F')", null: false
52
- <%- end -%>
53
- t.date "hire_date", null: false
54
- end
55
-
56
- create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
57
- t.integer "emp_no", null: false
58
- t.integer "salary", null: false
59
- t.date "from_date", null: false
60
- t.date "to_date", null: false
61
- t.index ["emp_no"], name: "emp_no"
62
- end
63
-
64
- create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
65
- t.integer "emp_no", null: false
66
- t.string "title", limit: 50, null: false
67
- t.date "from_date", null: false
68
- t.date "to_date"
69
- t.index ["emp_no"], name: "emp_no"
70
- end
71
- ERB
72
- }
73
- end
74
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#dump' do
4
- context 'when there is a tables' do
5
- before { restore_tables_mysql_unknown_column_type }
6
- subject { client }
7
-
8
- it {
9
- expect(subject.dump).to match_fuzzy erbh(<<-ERB)
10
- create_table "clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true } }) %>, force: :cascade do |t|
11
- t.string "name", default: "", null: false
12
- t.index ["name"], name: "idx_name", unique: true
13
- end
14
- ERB
15
- }
16
-
17
- it {
18
- expect(Ridgepole::Logger.instance).to receive(:warn).twice
19
- subject.dump
20
- }
21
-
22
- it {
23
- expect(Ridgepole::Logger.instance).to receive(:warn).with('[WARNING] Could not dump table "places" because of following StandardError')
24
- expect(Ridgepole::Logger.instance).to receive(:warn).with(" Unknown type 'geometry' for column 'location'")
25
- subject.dump
26
- }
27
- end
28
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#dump' do
4
- let(:actual_dsl) do
5
- erbh(<<-'ERB')
6
- create_table "books", unsigned: true, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='\"london\" bridge \"is\" falling \"down\"'" do |t|
7
- t.string "title", null: false
8
- t.integer "author_id", null: false
9
- t.datetime "created_at"
10
- t.datetime "updated_at"
11
- end
12
- ERB
13
- end
14
-
15
- context 'when without table options' do
16
- let(:expected_dsl) do
17
- erbh(<<-ERB)
18
- create_table "books", <%= i cond('>= 6.1', { id: { type: :bigint, unsigned: true } }, { id: :bigint, unsigned: true }) %>, force: :cascade, comment: "\\"london\\" bridge \\"is\\" falling \\"down\\"" do |t|
19
- t.string "title", null: false
20
- t.integer "author_id", null: false
21
- t.datetime "created_at"
22
- t.datetime "updated_at"
23
- end
24
- ERB
25
- end
26
-
27
- before { subject.diff(actual_dsl).migrate }
28
- subject { client }
29
-
30
- it {
31
- expect(subject.dump).to match_ruby expected_dsl
32
- }
33
- end
34
- end