ridgepole 0.8.9 → 0.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +83 -0
- data/.rubocop.yml +9 -34
- data/.simplecov +6 -0
- data/Appraisals +4 -5
- data/README.md +25 -40
- data/bin/ridgepole +13 -3
- data/gemfiles/{activerecord_5.0.gemfile → activerecord_6.1.gemfile} +1 -2
- data/lib/ridgepole/client.rb +8 -3
- data/lib/ridgepole/default_limit.rb +1 -1
- data/lib/ridgepole/delta.rb +16 -1
- data/lib/ridgepole/diff.rb +50 -31
- data/lib/ridgepole/dsl_parser.rb +3 -5
- data/lib/ridgepole/dsl_parser/context.rb +1 -1
- data/lib/ridgepole/dsl_parser/table_definition.rb +52 -42
- data/lib/ridgepole/execute_expander.rb +10 -1
- data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +9 -1
- data/lib/ridgepole/external_sql_executer.rb +12 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +7 -4
- data/spec/erb_helper.rb +5 -5
- data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +2 -2
- data/spec/mysql/bigint_pk/int_pk_spec.rb +1 -1
- data/spec/mysql/cli/ridgepole_spec.rb +35 -1
- data/spec/mysql/collation/collation_spec.rb +15 -15
- data/spec/mysql/comment/comment_spec.rb +9 -9
- data/spec/mysql/diff/diff2_spec.rb +5 -5
- data/spec/mysql/diff/diff_spec.rb +3 -3
- data/spec/mysql/dump/dump_class_method_spec.rb +13 -13
- data/spec/mysql/dump/dump_some_tables_spec.rb +4 -4
- data/spec/mysql/dump/dump_spec.rb +13 -13
- data/spec/mysql/dump/dump_unknown_column_type_spec.rb +2 -2
- data/spec/mysql/dump/dump_without_table_options_spec.rb +2 -2
- data/spec/mysql/fk/migrate_change_fk2_spec.rb +2 -2
- data/spec/mysql/fk/migrate_change_fk_spec.rb +20 -20
- data/spec/mysql/fk/migrate_create_fk_spec.rb +73 -24
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +26 -26
- data/spec/mysql/fk/migrate_fk_with_column_spec.rb +16 -16
- data/spec/mysql/fk/migrate_ignore_fk_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_add_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +106 -18
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +116 -25
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +3 -3
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +7 -7
- data/spec/mysql/migrate/migrate_change_column8_spec.rb +38 -5
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +2 -14
- data/spec/mysql/migrate/migrate_change_column_spec.rb +21 -21
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +7 -7
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +27 -27
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_index8_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_index_spec.rb +34 -28
- data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +24 -24
- data/spec/mysql/migrate/migrate_create_index_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_create_table_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +1 -1
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +15 -15
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_empty_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_execute_spec.rb +32 -32
- data/spec/mysql/migrate/migrate_ignore_column_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_ignore_index_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_log_file_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_noop_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_primary_key_spec.rb +31 -6
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +22 -22
- data/spec/mysql/migrate/migrate_same_spec.rb +13 -13
- data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +18 -18
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +2 -2
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +9 -9
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
- data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +5 -5
- data/spec/mysql57/json/add_json_column_spec.rb +2 -2
- data/spec/mysql57/json/change_json_column_spec.rb +6 -6
- data/spec/mysql57/json/drop_json_column_spec.rb +2 -2
- data/spec/mysql57/virtual/add_virtual_column_spec.rb +1 -1
- data/spec/mysql57/virtual/change_virtual_column_spec.rb +1 -1
- data/spec/mysql57/virtual/drop_virtual_column_spec.rb +1 -1
- data/spec/postgresql/dump/dump_spec.rb +13 -13
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +5 -5
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +27 -20
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +20 -16
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +18 -18
- data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +14 -14
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +29 -22
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +17 -17
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +15 -15
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +16 -16
- data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_primary_key_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_references_spec.rb +6 -6
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +18 -18
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_same_spec.rb +13 -13
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +3 -3
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +4 -4
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +4 -4
- data/spec/processing_for_ci.rb +13 -0
- data/spec/spec_condition.rb +4 -0
- data/spec/spec_helper.rb +3 -2
- metadata +74 -49
- data/.travis.yml +0 -45
- data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +0 -31
- data/omnibus-ridgepole/.gitignore +0 -10
- data/omnibus-ridgepole/Dockerfile.centos +0 -25
- data/omnibus-ridgepole/Dockerfile.ubuntu +0 -21
- data/omnibus-ridgepole/Gemfile +0 -24
- data/omnibus-ridgepole/README.md +0 -15
- data/omnibus-ridgepole/Rakefile +0 -38
- data/omnibus-ridgepole/config/projects/ridgepole.rb +0 -27
- data/omnibus-ridgepole/config/software/ridgepole.rb +0 -13
- data/omnibus-ridgepole/omnibus.rb +0 -54
- data/omnibus-ridgepole/package-scripts/ridgepole/postinst +0 -1
- data/omnibus-ridgepole/package-scripts/ridgepole/postrm +0 -1
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +0 -47
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +0 -141
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +0 -141
- data/spec/processing_for_travis.rb +0 -11
@@ -82,9 +82,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
82
82
|
expect(subject.dump).to match_ruby actual_dsl
|
83
83
|
|
84
84
|
expect(sql).to match_fuzzy erbh(<<-ERB)
|
85
|
-
CREATE TABLE `clubs` (`id`
|
85
|
+
CREATE TABLE `clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
86
86
|
CREATE UNIQUE INDEX `idx_name` USING btree ON `clubs` (`name`)
|
87
|
-
CREATE TABLE `departments` (`dept_no`
|
87
|
+
CREATE TABLE `departments` (`dept_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `dept_name` varchar(40) NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
88
88
|
CREATE UNIQUE INDEX `dept_name` USING btree ON `departments` (`dept_name`)
|
89
89
|
CREATE TABLE `dept_emp` (`emp_no` int NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
90
90
|
CREATE INDEX `dept_no` USING btree ON `dept_emp` (`dept_no`)
|
@@ -92,9 +92,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
92
92
|
CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
93
93
|
CREATE INDEX `dept_no` USING btree ON `dept_manager` (`dept_no`)
|
94
94
|
CREATE INDEX `emp_no` USING btree ON `dept_manager` (`emp_no`)
|
95
|
-
CREATE TABLE `employee_clubs` (`id`
|
95
|
+
CREATE TABLE `employee_clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
96
96
|
CREATE INDEX `idx_emp_no_club_id` USING btree ON `employee_clubs` (`emp_no`, `club_id`)
|
97
|
-
CREATE TABLE `employees` (`emp_no`
|
97
|
+
CREATE TABLE `employees` (`emp_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` varchar(1) NOT NULL, `hire_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
98
98
|
CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
99
99
|
CREATE INDEX `emp_no` USING btree ON `salaries` (`emp_no`)
|
100
100
|
CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
@@ -111,17 +111,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
111
111
|
|
112
112
|
# XXX:
|
113
113
|
expect(sql.delete('`')).to match_fuzzy erbh(<<-ERB).delete('`')
|
114
|
-
CREATE TABLE `clubs` (`id`
|
114
|
+
CREATE TABLE `clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
115
115
|
ALTER TABLE `clubs` ADD UNIQUE INDEX `idx_name` USING btree (`name`)
|
116
|
-
CREATE TABLE `departments` (`dept_no`
|
116
|
+
CREATE TABLE `departments` (`dept_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `dept_name` varchar(40) NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
117
117
|
ALTER TABLE `departments` ADD UNIQUE INDEX `dept_name` USING btree (`dept_name`)
|
118
118
|
CREATE TABLE `dept_emp` (`emp_no` int NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
119
119
|
ALTER TABLE `dept_emp` ADD INDEX `dept_no` USING btree (`dept_no`), ADD INDEX `emp_no` USING btree (`emp_no`)
|
120
120
|
CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
121
121
|
ALTER TABLE `dept_manager` ADD INDEX `dept_no` USING btree (`dept_no`), ADD INDEX `emp_no` USING btree (`emp_no`)
|
122
|
-
CREATE TABLE `employee_clubs` (`id`
|
122
|
+
CREATE TABLE `employee_clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
123
123
|
ALTER TABLE `employee_clubs` ADD INDEX `idx_emp_no_club_id` USING btree (`emp_no`, `club_id`)
|
124
|
-
CREATE TABLE `employees` (`emp_no`
|
124
|
+
CREATE TABLE `employees` (`emp_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` varchar(1) NOT NULL, `hire_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
125
125
|
CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
126
126
|
ALTER TABLE `salaries` ADD INDEX `emp_no` USING btree (`emp_no`)
|
127
127
|
CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
@@ -211,9 +211,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
211
211
|
expect(subject.dump).to match_ruby actual_dsl
|
212
212
|
|
213
213
|
expect(sql).to match_fuzzy erbh(<<-ERB)
|
214
|
-
CREATE TABLE `clubs` (`id`
|
214
|
+
CREATE TABLE `clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
215
215
|
CREATE UNIQUE INDEX `idx_name` USING btree ON `clubs` (`name`)
|
216
|
-
CREATE TABLE `departments` (`dept_no`
|
216
|
+
CREATE TABLE `departments` (`dept_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `dept_name` varchar(40) NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
217
217
|
CREATE UNIQUE INDEX `dept_name` USING btree ON `departments` (`dept_name`)
|
218
218
|
CREATE TABLE `dept_emp` (`emp_no` int NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
219
219
|
CREATE INDEX `dept_no` USING btree ON `dept_emp` (`dept_no`)
|
@@ -221,9 +221,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
221
221
|
CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
222
222
|
CREATE INDEX `dept_no` USING btree ON `dept_manager` (`dept_no`)
|
223
223
|
CREATE INDEX `emp_no` USING btree ON `dept_manager` (`emp_no`)
|
224
|
-
CREATE TABLE `employee_clubs` (`id`
|
224
|
+
CREATE TABLE `employee_clubs` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
225
225
|
CREATE INDEX `idx_emp_no_club_id` USING btree ON `employee_clubs` (`emp_no`, `club_id`)
|
226
|
-
CREATE TABLE `employees` (`emp_no`
|
226
|
+
CREATE TABLE `employees` (`emp_no` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` varchar(1) NOT NULL, `hire_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
227
227
|
CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
228
228
|
CREATE INDEX `emp_no` USING btree ON `salaries` (`emp_no`)
|
229
229
|
CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) <%= cond('< 5.2.0.beta2', 'ENGINE=InnoDB') %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
describe 'Ridgepole::Client#diff -> migrate' do
|
4
4
|
let(:actual_dsl) do
|
5
5
|
erbh(<<-ERB)
|
6
|
-
create_table "employees", id: :integer, unsigned: true, force: :cascade do |t|
|
6
|
+
create_table "employees", <%= i cond(">= 6.1", { id: { type: :integer, unsigned: true } }, { id: :integer, unsigned: true }) %>, force: :cascade do |t|
|
7
7
|
end
|
8
8
|
ERB
|
9
9
|
end
|
@@ -23,11 +23,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it {
|
26
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-
|
26
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(<<-ERB))
|
27
27
|
[WARNING] Primary key definition of `employees` differ but `allow_pk_change` option is false
|
28
|
-
from: {:id=>:integer, :unsigned=>true}
|
28
|
+
from: <%= i cond(">= 6.1", "{:id=>{:type=>:integer, :unsigned=>true}}", "{:id=>:integer, :unsigned=>true}") %>
|
29
29
|
to: {:id=>:bigint, :unsigned=>true}
|
30
|
-
|
30
|
+
ERB
|
31
31
|
|
32
32
|
delta = subject.diff(expected_dsl)
|
33
33
|
expect(delta.differ?).to be_falsey
|
@@ -58,12 +58,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
58
58
|
let(:allow_pk_change) { true }
|
59
59
|
let(:expected_dsl) do
|
60
60
|
erbh(<<-ERB)
|
61
|
-
create_table "employees", id: :bigint, unsigned: true, force: :cascade do |t|
|
61
|
+
create_table "employees", <%= i cond(">= 6.1", { id: { type: :bigint, unsigned: true } }, { id: :bigint, unsigned: true }) %>, force: :cascade do |t|
|
62
62
|
end
|
63
63
|
|
64
64
|
create_table "salaries", force: :cascade do |t|
|
65
65
|
t.bigint "employee_id", null: false, unsigned: true
|
66
|
-
t.index ["employee_id"], name: "fk_salaries_employees"
|
66
|
+
t.index ["employee_id"], name: "fk_salaries_employees"
|
67
67
|
end
|
68
68
|
add_foreign_key "salaries", "employees", name: "fk_salaries_employees"
|
69
69
|
ERB
|
@@ -76,4 +76,29 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
76
76
|
expect(subject.dump).to match_ruby expected_dsl
|
77
77
|
}
|
78
78
|
end
|
79
|
+
|
80
|
+
context 'when deafult: nil' do
|
81
|
+
let(:allow_pk_change) { true }
|
82
|
+
|
83
|
+
let(:actual_dsl) do
|
84
|
+
erbh(<<-ERB)
|
85
|
+
create_table "foo", id: :integer, unsigned: true, default: nil, force: :cascade do |t|
|
86
|
+
end
|
87
|
+
ERB
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:expected_dsl) do
|
91
|
+
erbh(<<-ERB)
|
92
|
+
create_table "foo", id: :integer, default: nil, force: :cascade do |t|
|
93
|
+
end
|
94
|
+
ERB
|
95
|
+
end
|
96
|
+
|
97
|
+
it {
|
98
|
+
delta = subject.diff(expected_dsl)
|
99
|
+
expect(delta.differ?).to be_truthy
|
100
|
+
delta.migrate
|
101
|
+
expect(subject.dump).to match_ruby expected_dsl
|
102
|
+
}
|
103
|
+
end
|
79
104
|
end
|
@@ -6,12 +6,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
6
6
|
erbh(<<-ERB)
|
7
7
|
create_table "clubs", force: :cascade do |t|
|
8
8
|
t.string "name", default: "", null: false
|
9
|
-
t.index ["name"], name: "idx_name", unique: true
|
9
|
+
t.index ["name"], name: "idx_name", unique: true
|
10
10
|
end
|
11
11
|
|
12
12
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
13
|
t.string "dept_name", limit: 40, null: false
|
14
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
14
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
15
15
|
end
|
16
16
|
|
17
17
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
19
19
|
t.string "dept_no", null: false
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
22
|
-
t.index ["dept_no"], name: "dept_no"
|
23
|
-
t.index ["emp_no"], name: "emp_no"
|
22
|
+
t.index ["dept_no"], name: "dept_no"
|
23
|
+
t.index ["emp_no"], name: "emp_no"
|
24
24
|
end
|
25
25
|
|
26
26
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
@@ -28,14 +28,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
28
28
|
t.integer "emp_no", null: false
|
29
29
|
t.date "from_date", null: false
|
30
30
|
t.date "to_date", null: false
|
31
|
-
t.index ["dept_no"], name: "dept_no"
|
32
|
-
t.index ["emp_no"], name: "emp_no"
|
31
|
+
t.index ["dept_no"], name: "dept_no"
|
32
|
+
t.index ["emp_no"], name: "emp_no"
|
33
33
|
end
|
34
34
|
|
35
35
|
create_table "employee_clubs", force: :cascade do |t|
|
36
36
|
t.integer "emp_no", null: false
|
37
37
|
t.integer "club_id", null: false
|
38
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
38
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
39
39
|
end
|
40
40
|
|
41
41
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
t.integer "salary", null: false
|
52
52
|
t.date "from_date", null: false
|
53
53
|
t.date "to_date", null: false
|
54
|
-
t.index ["emp_no"], name: "emp_no"
|
54
|
+
t.index ["emp_no"], name: "emp_no"
|
55
55
|
end
|
56
56
|
|
57
57
|
create_table "titles", id: false, force: :cascade do |t|
|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
59
59
|
t.string "title", limit: 50, null: false
|
60
60
|
t.date "from_date", null: false
|
61
61
|
t.date "to_date"
|
62
|
-
t.index ["emp_no"], name: "emp_no"
|
62
|
+
t.index ["emp_no"], name: "emp_no"
|
63
63
|
end
|
64
64
|
ERB
|
65
65
|
end
|
@@ -68,12 +68,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
68
68
|
erbh(<<-ERB)
|
69
69
|
create_table "clubs", force: :cascade do |t|
|
70
70
|
t.string "name", default: "", null: false
|
71
|
-
t.index ["name"], name: "idx_name", unique: true
|
71
|
+
t.index ["name"], name: "idx_name", unique: true
|
72
72
|
end
|
73
73
|
|
74
74
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
75
75
|
t.string "dept_name", limit: 40, null: false
|
76
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
76
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
77
77
|
end
|
78
78
|
|
79
79
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
81
81
|
t.string "dept_no", null: false
|
82
82
|
t.date "from_date2", null: false, renamed_from: 'from_date'
|
83
83
|
t.date "to_date", null: false
|
84
|
-
t.index ["dept_no"], name: "dept_no"
|
85
|
-
t.index ["emp_no"], name: "emp_no"
|
84
|
+
t.index ["dept_no"], name: "dept_no"
|
85
|
+
t.index ["emp_no"], name: "emp_no"
|
86
86
|
end
|
87
87
|
|
88
88
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
@@ -90,14 +90,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
90
90
|
t.integer "emp_no", null: false
|
91
91
|
t.date "from_date", null: false
|
92
92
|
t.date "to_date2", null: false, renamed_from: 'to_date'
|
93
|
-
t.index ["dept_no"], name: "dept_no"
|
94
|
-
t.index ["emp_no"], name: "emp_no"
|
93
|
+
t.index ["dept_no"], name: "dept_no"
|
94
|
+
t.index ["emp_no"], name: "emp_no"
|
95
95
|
end
|
96
96
|
|
97
97
|
create_table "employee_clubs", force: :cascade do |t|
|
98
98
|
t.integer "emp_no", null: false
|
99
99
|
t.integer "club_id", null: false
|
100
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
100
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
101
101
|
end
|
102
102
|
|
103
103
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
@@ -113,7 +113,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
113
113
|
t.integer "salary", null: false
|
114
114
|
t.date "from_date", null: false
|
115
115
|
t.date "to_date", null: false
|
116
|
-
t.index ["emp_no"], name: "emp_no"
|
116
|
+
t.index ["emp_no"], name: "emp_no"
|
117
117
|
end
|
118
118
|
|
119
119
|
create_table "titles", id: false, force: :cascade do |t|
|
@@ -121,7 +121,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
121
121
|
t.string "title", limit: 50, null: false
|
122
122
|
t.date "from_date", null: false
|
123
123
|
t.date "to_date"
|
124
|
-
t.index ["emp_no"], name: "emp_no"
|
124
|
+
t.index ["emp_no"], name: "emp_no"
|
125
125
|
end
|
126
126
|
ERB
|
127
127
|
end
|
@@ -6,12 +6,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
6
6
|
erbh(<<-ERB)
|
7
7
|
create_table "clubs", force: :cascade do |t|
|
8
8
|
t.string "name", default: "", null: false
|
9
|
-
t.index ["name"], name: "idx_name", unique: true
|
9
|
+
t.index ["name"], name: "idx_name", unique: true
|
10
10
|
end
|
11
11
|
|
12
12
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
13
|
t.string "dept_name", limit: 40, null: false
|
14
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
14
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
15
15
|
end
|
16
16
|
|
17
17
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
19
19
|
t.string "dept_no", null: false
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
22
|
-
t.index ["dept_no"], name: "dept_no"
|
23
|
-
t.index ["emp_no"], name: "emp_no"
|
22
|
+
t.index ["dept_no"], name: "dept_no"
|
23
|
+
t.index ["emp_no"], name: "emp_no"
|
24
24
|
end
|
25
25
|
|
26
26
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
@@ -28,14 +28,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
28
28
|
t.integer "emp_no", null: false
|
29
29
|
t.date "from_date", null: false
|
30
30
|
t.date "to_date", null: false
|
31
|
-
t.index ["dept_no"], name: "dept_no"
|
32
|
-
t.index ["emp_no"], name: "emp_no"
|
31
|
+
t.index ["dept_no"], name: "dept_no"
|
32
|
+
t.index ["emp_no"], name: "emp_no"
|
33
33
|
end
|
34
34
|
|
35
35
|
create_table "employee_clubs", force: :cascade do |t|
|
36
36
|
t.integer "emp_no", null: false
|
37
37
|
t.integer "club_id", null: false
|
38
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
38
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
39
39
|
end
|
40
40
|
|
41
41
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
t.integer "salary", null: false
|
52
52
|
t.date "from_date", null: false
|
53
53
|
t.date "to_date", null: false
|
54
|
-
t.index ["emp_no"], name: "emp_no"
|
54
|
+
t.index ["emp_no"], name: "emp_no"
|
55
55
|
end
|
56
56
|
|
57
57
|
create_table "titles", id: false, force: :cascade do |t|
|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
59
59
|
t.string "title", limit: 50, null: false
|
60
60
|
t.date "from_date", null: false
|
61
61
|
t.date "to_date"
|
62
|
-
t.index ["emp_no"], name: "emp_no"
|
62
|
+
t.index ["emp_no"], name: "emp_no"
|
63
63
|
end
|
64
64
|
ERB
|
65
65
|
end
|
@@ -68,12 +68,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
68
68
|
erbh(<<-ERB)
|
69
69
|
create_table "clubs", force: :cascade do |t|
|
70
70
|
t.string "name", default: "", null: false
|
71
|
-
t.index ["name"], name: "idx_name", unique: true
|
71
|
+
t.index ["name"], name: "idx_name", unique: true
|
72
72
|
end
|
73
73
|
|
74
74
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
75
75
|
t.string "dept_name", limit: 40, null: false
|
76
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
76
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
77
77
|
end
|
78
78
|
|
79
79
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
81
81
|
t.string "dept_no", null: false
|
82
82
|
t.date "from_date", null: false
|
83
83
|
t.date "to_date", null: false
|
84
|
-
t.index ["dept_no"], name: "dept_no"
|
85
|
-
t.index ["emp_no"], name: "emp_no"
|
84
|
+
t.index ["dept_no"], name: "dept_no"
|
85
|
+
t.index ["emp_no"], name: "emp_no"
|
86
86
|
end
|
87
87
|
|
88
88
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
@@ -90,14 +90,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
90
90
|
t.integer "emp_no", null: false
|
91
91
|
t.date "from_date", null: false
|
92
92
|
t.date "to_date", null: false
|
93
|
-
t.index ["dept_no"], name: "dept_no"
|
94
|
-
t.index ["emp_no"], name: "emp_no"
|
93
|
+
t.index ["dept_no"], name: "dept_no"
|
94
|
+
t.index ["emp_no"], name: "emp_no"
|
95
95
|
end
|
96
96
|
|
97
97
|
create_table "employee_clubs", force: :cascade do |t|
|
98
98
|
t.integer "emp_no", null: false
|
99
99
|
t.integer "club_id", null: false
|
100
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
100
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
101
101
|
end
|
102
102
|
|
103
103
|
create_table "employees2", primary_key: "emp_no", force: :cascade, renamed_from: 'employees' do |t|
|
@@ -113,7 +113,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
113
113
|
t.integer "salary", null: false
|
114
114
|
t.date "from_date", null: false
|
115
115
|
t.date "to_date", null: false
|
116
|
-
t.index ["emp_no"], name: "emp_no"
|
116
|
+
t.index ["emp_no"], name: "emp_no"
|
117
117
|
end
|
118
118
|
|
119
119
|
create_table "titles2", id: false, force: :cascade, renamed_from: :titles do |t|
|
@@ -121,7 +121,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
121
121
|
t.string "title", limit: 50, null: false
|
122
122
|
t.date "from_date", null: false
|
123
123
|
t.date "to_date"
|
124
|
-
t.index ["emp_no"], name: "emp_no"
|
124
|
+
t.index ["emp_no"], name: "emp_no"
|
125
125
|
end
|
126
126
|
ERB
|
127
127
|
end
|
@@ -147,7 +147,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
147
147
|
t.string "last_name", limit: 16, null: false
|
148
148
|
t.string "gender", limit: 1, null: false
|
149
149
|
t.date "hire_date", null: false
|
150
|
-
t.index ["first_name"], name: "first_name"
|
150
|
+
t.index ["first_name"], name: "first_name"
|
151
151
|
end
|
152
152
|
|
153
153
|
create_table "employees3", primary_key: "emp_no", force: :cascade do |t|
|
@@ -156,7 +156,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
156
156
|
t.string "last_name", limit: 16, null: false
|
157
157
|
t.string "gender", limit: 1, null: false
|
158
158
|
t.date "hire_date", null: false
|
159
|
-
t.index ["first_name"], name: "first_name"
|
159
|
+
t.index ["first_name"], name: "first_name"
|
160
160
|
end
|
161
161
|
ERB
|
162
162
|
end
|
@@ -169,7 +169,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
169
169
|
t.string "last_name", limit: 16, null: false
|
170
170
|
t.string "gender", limit: 1, null: false
|
171
171
|
t.date "hire_date", null: false
|
172
|
-
t.index ["first_name"], name: "first_name"
|
172
|
+
t.index ["first_name"], name: "first_name"
|
173
173
|
end
|
174
174
|
|
175
175
|
create_table "employees4", primary_key: "emp_no", force: :cascade, renamed_from: :employees3 do |t|
|
@@ -178,7 +178,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
178
178
|
t.string "last_name", limit: 16, null: false
|
179
179
|
t.string "gender", limit: 1, null: false
|
180
180
|
t.date "hire_date", null: false
|
181
|
-
t.index ["first_name"], name: "first_name"
|
181
|
+
t.index ["first_name"], name: "first_name"
|
182
182
|
end
|
183
183
|
ERB
|
184
184
|
end
|
@@ -4,14 +4,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
4
4
|
context 'when database and definition are same' do
|
5
5
|
let(:dsl) do
|
6
6
|
erbh(<<-ERB)
|
7
|
-
create_table "clubs", <%= i cond('
|
7
|
+
create_table "clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true } }) %>, force: :cascade do |t|
|
8
8
|
t.string "name", default: "", null: false
|
9
|
-
t.index ["name"], name: "idx_name", unique: true
|
9
|
+
t.index ["name"], name: "idx_name", unique: true
|
10
10
|
end
|
11
11
|
|
12
|
-
create_table "departments", primary_key: "dept_no", id: :string, limit: 4, force: :cascade do |t|
|
12
|
+
create_table "departments", primary_key: "dept_no", <%= i cond(">= 6.1", { id: { type: :string, limit: 4 } }, { id: :string, limit: 4 }) %>, force: :cascade do |t|
|
13
13
|
t.string "dept_name", limit: 40, null: false
|
14
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
14
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
15
15
|
end
|
16
16
|
|
17
17
|
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
19
19
|
t.string "dept_no", limit: 4, null: false
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
22
|
-
t.index ["dept_no"], name: "dept_no"
|
23
|
-
t.index ["emp_no"], name: "emp_no"
|
22
|
+
t.index ["dept_no"], name: "dept_no"
|
23
|
+
t.index ["emp_no"], name: "emp_no"
|
24
24
|
end
|
25
25
|
|
26
26
|
create_table "dept_manager", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
@@ -28,17 +28,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
28
28
|
t.integer "emp_no", null: false
|
29
29
|
t.date "from_date", null: false
|
30
30
|
t.date "to_date", null: false
|
31
|
-
t.index ["dept_no"], name: "dept_no"
|
32
|
-
t.index ["emp_no"], name: "emp_no"
|
31
|
+
t.index ["dept_no"], name: "dept_no"
|
32
|
+
t.index ["emp_no"], name: "emp_no"
|
33
33
|
end
|
34
34
|
|
35
|
-
create_table "employee_clubs", <%= i cond('
|
35
|
+
create_table "employee_clubs", <%= i cond('< 6.1', { id: :integer, unsigned: true }, { id: { type: :integer, unsigned: true } }) %>, force: :cascade do |t|
|
36
36
|
t.integer "emp_no", null: false, unsigned: true
|
37
37
|
t.integer "club_id", null: false, unsigned: true
|
38
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
38
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
39
39
|
end
|
40
40
|
|
41
|
-
create_table "employees", primary_key: "emp_no", id: :integer,
|
41
|
+
create_table "employees", primary_key: "emp_no", id: :integer, default: nil, force: :cascade do |t|
|
42
42
|
t.date "birth_date", null: false
|
43
43
|
t.string "first_name", limit: 14, null: false
|
44
44
|
t.string "last_name", limit: 16, null: false
|
@@ -55,7 +55,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
55
55
|
t.integer "salary", null: false
|
56
56
|
t.date "from_date", null: false
|
57
57
|
t.date "to_date", null: false
|
58
|
-
t.index ["emp_no"], name: "emp_no"
|
58
|
+
t.index ["emp_no"], name: "emp_no"
|
59
59
|
end
|
60
60
|
|
61
61
|
create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
|
@@ -63,7 +63,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
63
63
|
t.string "title", limit: 50, null: false
|
64
64
|
t.date "from_date", null: false
|
65
65
|
t.date "to_date"
|
66
|
-
t.index ["emp_no"], name: "emp_no"
|
66
|
+
t.index ["emp_no"], name: "emp_no"
|
67
67
|
end
|
68
68
|
ERB
|
69
69
|
end
|