ridgepole 0.6.0.beta2 → 0.6.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +2 -0
- data/bin/ridgepole +16 -16
- data/lib/ridgepole/client.rb +6 -9
- data/lib/ridgepole/default_limit.rb +26 -0
- data/lib/ridgepole/delta.rb +2 -8
- data/lib/ridgepole/diff.rb +14 -10
- data/lib/ridgepole/version.rb +1 -1
- data/lib/ridgepole.rb +2 -10
- data/ridgepole.gemspec +1 -0
- data/spec/{bigint_pk → mysql/bigint_pk}/bigint_pkspec.rb +0 -0
- data/spec/{cli → mysql/cli}/config_spec.rb +3 -1
- data/spec/{cli → mysql/cli}/ridgepole_spec.rb +3 -0
- data/spec/{collation → mysql/collation}/collation_spec.rb +2 -0
- data/spec/{diff → mysql/diff}/diff2_spec.rb +2 -0
- data/spec/{diff → mysql/diff}/diff_spec.rb +2 -0
- data/spec/{dump → mysql/dump}/dump_class_method_spec.rb +2 -0
- data/spec/{dump → mysql/dump}/dump_some_tables_spec.rb +2 -0
- data/spec/{dump → mysql/dump}/dump_spec.rb +2 -0
- data/spec/{dump → mysql/dump}/dump_without_table_options_spec.rb +2 -0
- data/spec/{migrate_0 → mysql/fk}/migrate_change_fk_spec.rb +5 -3
- data/spec/{migrate_0 → mysql/fk}/migrate_create_fk_spec.rb +7 -5
- data/spec/{migrate_0 → mysql/fk}/migrate_drop_fk_spec.rb +6 -4
- data/spec/{migrate → mysql/migrate}/check_orphan_index_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_add_column2_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_add_column_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_column2_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_column3_spec.rb +2 -0
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +83 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_column_float_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_column_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_index2_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_index3_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_index4_spec.rb +2 -0
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +78 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_index_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_change_table_option_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_create_index_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_create_table_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_create_table_with_options_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_drop_column_and_index_2_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_drop_column_and_index_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_drop_column_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_drop_index_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_drop_table_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_duplicate_index_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_duplicate_table_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_empty_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_execute_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_merge_mode_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_noop_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_rename_column_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_rename_table_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_same_default_null_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_same_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_script_error_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_skip_rename_column_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_skip_rename_table_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_with_ignore_tables_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_with_pre_post_query_spec.rb +2 -0
- data/spec/{migrate → mysql/migrate}/migrate_with_tables_spec.rb +2 -0
- data/spec/{ridgepole_test_database.sql → mysql/ridgepole_test_database.sql} +0 -0
- data/spec/{ridgepole_test_tables.sql → mysql/ridgepole_test_tables.sql} +0 -0
- data/spec/postgresql/diff/diff_spec.rb +153 -0
- data/spec/postgresql/dump/dump_spec.rb +76 -0
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +62 -0
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +173 -0
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +114 -0
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +220 -0
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +203 -0
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +193 -0
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +103 -0
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +185 -0
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +180 -0
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +125 -0
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +116 -0
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +179 -0
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +199 -0
- data/spec/postgresql/migrate/migrate_same_spec.rb +84 -0
- data/spec/postgresql/ridgepole_test_database.sql +15 -0
- data/spec/postgresql/ridgepole_test_tables.sql +74 -0
- data/spec/spec_helper.rb +63 -7
- metadata +159 -104
@@ -0,0 +1,78 @@
|
|
1
|
+
unless postgresql?
|
2
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
3
|
+
context 'when change index (unique: false)' do
|
4
|
+
let(:actual_dsl) {
|
5
|
+
<<-RUBY
|
6
|
+
create_table "salaries"#{unsigned_if_enabled}, force: :cascade do |t|
|
7
|
+
t.integer "emp_no", limit: 4, null: false
|
8
|
+
t.integer "salary", limit: 4, null: false
|
9
|
+
t.date "from_date", null: false
|
10
|
+
t.date "to_date", null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index "salaries", ["emp_no", "id"], name: "emp_no", using: :btree
|
14
|
+
RUBY
|
15
|
+
}
|
16
|
+
|
17
|
+
let(:expected_dsl) {
|
18
|
+
<<-RUBY
|
19
|
+
create_table "salaries"#{unsigned_if_enabled}, force: :cascade do |t|
|
20
|
+
t.integer "emp_no", limit: 4, null: false
|
21
|
+
t.integer "salary", limit: 4, null: false
|
22
|
+
t.date "from_date", null: false
|
23
|
+
t.date "to_date", null: false
|
24
|
+
end
|
25
|
+
|
26
|
+
add_index "salaries", ["emp_no", "id"], unique: false, name: "emp_no", unique: false, using: :btree
|
27
|
+
RUBY
|
28
|
+
}
|
29
|
+
|
30
|
+
before { subject.diff(actual_dsl).migrate }
|
31
|
+
subject { client }
|
32
|
+
|
33
|
+
it {
|
34
|
+
delta = subject.diff(expected_dsl)
|
35
|
+
expect(delta.differ?).to be_falsy
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when change index (unique: true)' do
|
40
|
+
let(:actual_dsl) {
|
41
|
+
<<-RUBY
|
42
|
+
create_table "salaries"#{unsigned_if_enabled}, force: :cascade do |t|
|
43
|
+
t.integer "emp_no", limit: 4, null: false
|
44
|
+
t.integer "salary", limit: 4, null: false
|
45
|
+
t.date "from_date", null: false
|
46
|
+
t.date "to_date", null: false
|
47
|
+
end
|
48
|
+
|
49
|
+
add_index "salaries", ["emp_no", "id"], name: "emp_no", using: :btree
|
50
|
+
RUBY
|
51
|
+
}
|
52
|
+
|
53
|
+
let(:expected_dsl) {
|
54
|
+
<<-RUBY
|
55
|
+
create_table "salaries"#{unsigned_if_enabled}, force: :cascade do |t|
|
56
|
+
t.integer "emp_no", limit: 4, null: false
|
57
|
+
t.integer "salary", limit: 4, null: false
|
58
|
+
t.date "from_date", null: false
|
59
|
+
t.date "to_date", null: false
|
60
|
+
end
|
61
|
+
|
62
|
+
add_index "salaries", ["emp_no", "id"], name: "emp_no", unique: true, using: :btree
|
63
|
+
RUBY
|
64
|
+
}
|
65
|
+
|
66
|
+
before { subject.diff(actual_dsl).migrate }
|
67
|
+
subject { client }
|
68
|
+
|
69
|
+
it {
|
70
|
+
delta = subject.diff(expected_dsl)
|
71
|
+
expect(delta.differ?).to be_truthy
|
72
|
+
expect(subject.dump.delete_empty_lines).to eq actual_dsl.strip_heredoc.strip.delete_empty_lines
|
73
|
+
delta.migrate
|
74
|
+
expect(subject.dump.delete_empty_lines).to eq expected_dsl.strip_heredoc.strip.delete_empty_lines
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
unless postgresql?
|
1
2
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
3
|
context 'when database and definition are same (default null / nothing -> null:true)' do
|
3
4
|
let(:actual_dsl) {
|
@@ -73,3 +74,4 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
73
74
|
}
|
74
75
|
end
|
75
76
|
end
|
77
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,153 @@
|
|
1
|
+
if postgresql?
|
2
|
+
describe 'Ridgepole::Client.diff' do
|
3
|
+
context 'when change column' do
|
4
|
+
let(:actual_dsl) {
|
5
|
+
<<-RUBY
|
6
|
+
create_table "clubs", force: :cascade do |t|
|
7
|
+
t.string "name", limit: 255, default: "", null: false
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
11
|
+
|
12
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
|
+
t.string "dept_name", limit: 40, null: false
|
14
|
+
end
|
15
|
+
|
16
|
+
add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree
|
17
|
+
|
18
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
19
|
+
t.integer "emp_no", null: false
|
20
|
+
t.string "dept_no", limit: 4, null: false
|
21
|
+
t.date "from_date", null: false
|
22
|
+
t.date "to_date", null: false
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree
|
26
|
+
add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree
|
27
|
+
|
28
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
29
|
+
t.string "dept_no", limit: 4, null: false
|
30
|
+
t.integer "emp_no", null: false
|
31
|
+
t.date "from_date", null: false
|
32
|
+
t.date "to_date", null: false
|
33
|
+
end
|
34
|
+
|
35
|
+
add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree
|
36
|
+
add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree
|
37
|
+
|
38
|
+
create_table "employee_clubs", force: :cascade do |t|
|
39
|
+
t.integer "emp_no", null: false
|
40
|
+
t.integer "club_id", null: false
|
41
|
+
end
|
42
|
+
|
43
|
+
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", using: :btree
|
44
|
+
|
45
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
46
|
+
t.date "birth_date", null: false
|
47
|
+
t.string "first_name", limit: 14, null: false
|
48
|
+
t.string "last_name", limit: 16, null: false
|
49
|
+
t.date "hire_date", null: false
|
50
|
+
end
|
51
|
+
|
52
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
+
t.integer "emp_no", null: false
|
54
|
+
t.integer "salary", null: false
|
55
|
+
t.date "from_date", null: false
|
56
|
+
t.date "to_date", null: false
|
57
|
+
end
|
58
|
+
|
59
|
+
add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree
|
60
|
+
|
61
|
+
create_table "titles", id: false, force: :cascade do |t|
|
62
|
+
t.integer "emp_no", null: false
|
63
|
+
t.string "title", limit: 50, null: false
|
64
|
+
t.date "from_date", null: false
|
65
|
+
t.date "to_date"
|
66
|
+
end
|
67
|
+
|
68
|
+
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
69
|
+
RUBY
|
70
|
+
}
|
71
|
+
|
72
|
+
let(:expected_dsl) {
|
73
|
+
<<-RUBY
|
74
|
+
create_table "clubs", force: :cascade do |t|
|
75
|
+
t.string "name", limit: 255, default: "", null: false
|
76
|
+
end
|
77
|
+
|
78
|
+
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
79
|
+
|
80
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
81
|
+
t.string "dept_name", limit: 40, null: false
|
82
|
+
end
|
83
|
+
|
84
|
+
add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree
|
85
|
+
|
86
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
+
t.integer "emp_no", null: false
|
88
|
+
t.string "dept_no", limit: 4, null: false
|
89
|
+
t.date "from_date", null: false
|
90
|
+
t.date "to_date", null: false
|
91
|
+
end
|
92
|
+
|
93
|
+
add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree
|
94
|
+
add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree
|
95
|
+
|
96
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
97
|
+
t.string "dept_no", limit: 4, null: false
|
98
|
+
t.integer "emp_no", null: false
|
99
|
+
t.date "from_date", null: false
|
100
|
+
t.date "to_date", null: false
|
101
|
+
end
|
102
|
+
|
103
|
+
add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree
|
104
|
+
add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree
|
105
|
+
|
106
|
+
create_table "employee_clubs", force: :cascade do |t|
|
107
|
+
t.integer "emp_no", null: false
|
108
|
+
t.integer "club_id", null: true
|
109
|
+
end
|
110
|
+
|
111
|
+
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", using: :btree
|
112
|
+
|
113
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
114
|
+
t.date "birth_date", null: false
|
115
|
+
t.string "first_name", limit: 14, null: false
|
116
|
+
t.string "last_name", limit: 20, default: "XXX", null: false
|
117
|
+
t.date "hire_date", null: false
|
118
|
+
end
|
119
|
+
|
120
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
121
|
+
t.integer "emp_no", null: false
|
122
|
+
t.integer "salary", null: false
|
123
|
+
t.date "from_date", null: false
|
124
|
+
t.date "to_date", null: false
|
125
|
+
end
|
126
|
+
|
127
|
+
add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree
|
128
|
+
|
129
|
+
create_table "titles", id: false, force: :cascade do |t|
|
130
|
+
t.integer "emp_no", null: false
|
131
|
+
t.string "title", limit: 50, null: false
|
132
|
+
t.date "from_date", null: false
|
133
|
+
t.date "to_date"
|
134
|
+
end
|
135
|
+
|
136
|
+
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
137
|
+
RUBY
|
138
|
+
}
|
139
|
+
|
140
|
+
subject { Ridgepole::Client }
|
141
|
+
|
142
|
+
it {
|
143
|
+
delta = subject.diff(actual_dsl, expected_dsl, enable_mysql_unsigned: true)
|
144
|
+
expect(delta.differ?).to be_truthy
|
145
|
+
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
146
|
+
change_column("employee_clubs", "club_id", :integer, {:null=>true, :default=>nil})
|
147
|
+
|
148
|
+
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX", :null=>false})
|
149
|
+
RUBY
|
150
|
+
}
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
if postgresql?
|
2
|
+
describe 'Ridgepole::Client#dump' do
|
3
|
+
context 'when there is a tables' do
|
4
|
+
before { restore_tables }
|
5
|
+
subject { client }
|
6
|
+
|
7
|
+
it {
|
8
|
+
expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
|
9
|
+
create_table "clubs", force: :cascade do |t|
|
10
|
+
t.string "name", limit: 255, default: "", null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
14
|
+
|
15
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
16
|
+
t.string "dept_name", limit: 40, null: false
|
17
|
+
end
|
18
|
+
|
19
|
+
add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree
|
20
|
+
|
21
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
22
|
+
t.integer "emp_no", null: false
|
23
|
+
t.string "dept_no", limit: 4, null: false
|
24
|
+
t.date "from_date", null: false
|
25
|
+
t.date "to_date", null: false
|
26
|
+
end
|
27
|
+
|
28
|
+
add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree
|
29
|
+
add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree
|
30
|
+
|
31
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
32
|
+
t.string "dept_no", limit: 4, null: false
|
33
|
+
t.integer "emp_no", null: false
|
34
|
+
t.date "from_date", null: false
|
35
|
+
t.date "to_date", null: false
|
36
|
+
end
|
37
|
+
|
38
|
+
add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree
|
39
|
+
add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree
|
40
|
+
|
41
|
+
create_table "employee_clubs", force: :cascade do |t|
|
42
|
+
t.integer "emp_no", null: false
|
43
|
+
t.integer "club_id", null: false
|
44
|
+
end
|
45
|
+
|
46
|
+
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", using: :btree
|
47
|
+
|
48
|
+
create_table "employees", primary_key: "emp_no", 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
|
+
t.date "hire_date", null: false
|
53
|
+
end
|
54
|
+
|
55
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
56
|
+
t.integer "emp_no", null: false
|
57
|
+
t.integer "salary", null: false
|
58
|
+
t.date "from_date", null: false
|
59
|
+
t.date "to_date", null: false
|
60
|
+
end
|
61
|
+
|
62
|
+
add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree
|
63
|
+
|
64
|
+
create_table "titles", id: false, 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
|
+
end
|
70
|
+
|
71
|
+
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
72
|
+
RUBY
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|