ridgepole 0.5.3.beta4 → 0.6.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -50
- data/bin/ridgepole +8 -18
- data/lib/ridgepole/client.rb +10 -16
- data/lib/ridgepole/delta.rb +57 -19
- data/lib/ridgepole/diff.rb +45 -14
- data/lib/ridgepole/dsl_parser.rb +38 -8
- data/lib/ridgepole/execute_expander.rb +0 -29
- data/lib/ridgepole/ext/mysql_awesome.rb +1 -5
- data/lib/ridgepole/version.rb +1 -1
- data/lib/ridgepole.rb +10 -2
- data/ridgepole.gemspec +3 -8
- data/spec/bigint_pk/bigint_pkspec.rb +2 -2
- data/spec/cli/ridgepole_spec.rb +3 -5
- data/spec/collation/collation_spec.rb +35 -35
- data/spec/diff/diff2_spec.rb +18 -18
- data/spec/diff/diff_spec.rb +18 -18
- data/spec/dump/dump_class_method_spec.rb +18 -18
- data/spec/dump/dump_some_tables_spec.rb +12 -12
- data/spec/dump/dump_spec.rb +18 -18
- data/spec/dump/dump_without_table_options_spec.rb +6 -6
- data/spec/migrate/check_orphan_index_spec.rb +8 -8
- data/spec/migrate/migrate_add_column2_spec.rb +15 -15
- data/spec/migrate/migrate_add_column_spec.rb +40 -40
- data/spec/migrate/migrate_change_column2_spec.rb +5 -5
- data/spec/migrate/migrate_change_column3_spec.rb +26 -26
- data/spec/migrate/migrate_change_column_float_spec.rb +7 -7
- data/spec/migrate/migrate_change_column_spec.rb +42 -42
- data/spec/migrate/migrate_change_index2_spec.rb +13 -13
- data/spec/migrate/migrate_change_index3_spec.rb +26 -26
- data/spec/migrate/migrate_change_index4_spec.rb +28 -28
- data/spec/migrate/migrate_change_index_spec.rb +46 -46
- data/spec/migrate/migrate_change_table_option_spec.rb +2 -2
- data/spec/migrate/migrate_create_index_spec.rb +18 -18
- data/spec/migrate/migrate_create_table_spec.rb +18 -18
- data/spec/migrate/migrate_create_table_with_options_spec.rb +3 -3
- data/spec/migrate/migrate_drop_column_and_index_2_spec.rb +35 -35
- data/spec/migrate/migrate_drop_column_and_index_spec.rb +33 -33
- data/spec/migrate/migrate_drop_column_spec.rb +36 -36
- data/spec/migrate/migrate_drop_index_spec.rb +18 -18
- data/spec/migrate/migrate_drop_table_spec.rb +24 -24
- data/spec/migrate/migrate_duplicate_index_spec.rb +1 -1
- data/spec/migrate/migrate_duplicate_table_spec.rb +2 -2
- data/spec/migrate/migrate_empty_spec.rb +18 -18
- data/spec/migrate/migrate_execute_spec.rb +58 -49
- data/spec/migrate/migrate_merge_mode_spec.rb +38 -38
- data/spec/migrate/migrate_noop_spec.rb +40 -40
- data/spec/migrate/migrate_rename_column_spec.rb +37 -37
- data/spec/migrate/migrate_rename_table_spec.rb +39 -39
- data/spec/migrate/migrate_same_default_null_spec.rb +4 -4
- data/spec/migrate/migrate_same_spec.rb +18 -18
- data/spec/migrate/migrate_script_error_spec.rb +8 -8
- data/spec/migrate/migrate_skip_rename_column_spec.rb +36 -36
- data/spec/migrate/migrate_skip_rename_table_spec.rb +36 -36
- data/spec/migrate/migrate_with_ignore_tables_spec.rb +12 -12
- data/spec/migrate/migrate_with_pre_post_query_spec.rb +32 -32
- data/spec/migrate/migrate_with_tables_spec.rb +12 -12
- data/spec/migrate_0/migrate_change_fk_spec.rb +11 -11
- data/spec/migrate_0/migrate_create_fk_spec.rb +29 -30
- data/spec/migrate_0/migrate_drop_fk_spec.rb +22 -23
- data/spec/spec_helper.rb +24 -2
- metadata +10 -89
- data/lib/ridgepole/ext/foreign_key.rb +0 -121
- data/spec/0_diff/dump_disable_unsigned_spec.rb +0 -75
- data/spec/comment/comment_spec.rb +0 -179
- data/spec/migrate/migrate_same_default_unsigned_spec.rb +0 -63
- data/spec/~pkdump/pkdump_spec.rb +0 -67
@@ -2,20 +2,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when rename table' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "clubs", force:
|
6
|
-
t.string "name", default: "", null: false
|
5
|
+
create_table "clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
6
|
+
t.string "name", limit: 255, default: "", null: false
|
7
7
|
end
|
8
8
|
|
9
9
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
10
10
|
|
11
|
-
create_table "departments", primary_key: "dept_no", force:
|
11
|
+
create_table "departments", primary_key: "dept_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
12
12
|
t.string "dept_name", limit: 40, null: false
|
13
13
|
end
|
14
14
|
|
15
15
|
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
16
16
|
|
17
|
-
create_table "dept_emp", id: false, force:
|
18
|
-
t.integer "emp_no",
|
17
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
+
t.integer "emp_no", limit: 4, null: false
|
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
|
@@ -24,9 +24,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
24
24
|
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
25
25
|
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
26
26
|
|
27
|
-
create_table "dept_manager", id: false, force:
|
27
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
28
28
|
t.string "dept_no", limit: 4, null: false
|
29
|
-
t.integer "emp_no",
|
29
|
+
t.integer "emp_no", limit: 4, null: false
|
30
30
|
t.date "from_date", null: false
|
31
31
|
t.date "to_date", null: false
|
32
32
|
end
|
@@ -34,14 +34,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
34
34
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
35
35
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
36
36
|
|
37
|
-
create_table "employee_clubs", force:
|
38
|
-
t.integer "emp_no",
|
39
|
-
t.integer "club_id",
|
37
|
+
create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
38
|
+
t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
|
39
|
+
t.integer "club_id", limit: 4, null: false#{unsigned_if_enabled}
|
40
40
|
end
|
41
41
|
|
42
42
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
43
43
|
|
44
|
-
create_table "employees2", primary_key: "emp_no", force:
|
44
|
+
create_table "employees2", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
45
45
|
t.date "birth_date", null: false
|
46
46
|
t.string "first_name", limit: 14, null: false
|
47
47
|
t.string "last_name", limit: 16, null: false
|
@@ -49,17 +49,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
49
49
|
t.date "hire_date", null: false
|
50
50
|
end
|
51
51
|
|
52
|
-
create_table "salaries", id: false, force:
|
53
|
-
t.integer "emp_no", null: false
|
54
|
-
t.integer "salary", null: false
|
55
|
-
t.date "from_date",
|
56
|
-
t.date "to_date",
|
52
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
+
t.integer "emp_no", limit: 4, null: false
|
54
|
+
t.integer "salary", limit: 4, null: false
|
55
|
+
t.date "from_date", null: false
|
56
|
+
t.date "to_date", null: false
|
57
57
|
end
|
58
58
|
|
59
59
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
60
60
|
|
61
|
-
create_table "titles", id: false, force:
|
62
|
-
t.integer "emp_no",
|
61
|
+
create_table "titles", id: false, force: :cascade do |t|
|
62
|
+
t.integer "emp_no", limit: 4, null: false
|
63
63
|
t.string "title", limit: 50, null: false
|
64
64
|
t.date "from_date", null: false
|
65
65
|
t.date "to_date"
|
@@ -71,20 +71,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
71
71
|
|
72
72
|
let(:expected_dsl) {
|
73
73
|
<<-RUBY
|
74
|
-
create_table "clubs", force:
|
75
|
-
t.string "name", default: "", null: false
|
74
|
+
create_table "clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
75
|
+
t.string "name", limit: 255, default: "", null: false
|
76
76
|
end
|
77
77
|
|
78
78
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
79
79
|
|
80
|
-
create_table "departments", primary_key: "dept_no", force:
|
80
|
+
create_table "departments", primary_key: "dept_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
81
81
|
t.string "dept_name", limit: 40, null: false
|
82
82
|
end
|
83
83
|
|
84
84
|
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
85
85
|
|
86
|
-
create_table "dept_emp", id: false, force:
|
87
|
-
t.integer "emp_no",
|
86
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
+
t.integer "emp_no", limit: 4, null: false
|
88
88
|
t.string "dept_no", limit: 4, null: false
|
89
89
|
t.date "from_date", null: false
|
90
90
|
t.date "to_date", null: false
|
@@ -93,9 +93,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
93
93
|
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
94
94
|
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
95
95
|
|
96
|
-
create_table "dept_manager", id: false, force:
|
96
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
97
97
|
t.string "dept_no", limit: 4, null: false
|
98
|
-
t.integer "emp_no",
|
98
|
+
t.integer "emp_no", limit: 4, null: false
|
99
99
|
t.date "from_date", null: false
|
100
100
|
t.date "to_date", null: false
|
101
101
|
end
|
@@ -103,14 +103,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
103
103
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
104
104
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
105
105
|
|
106
|
-
create_table "employee_clubs", force:
|
107
|
-
t.integer "emp_no",
|
108
|
-
t.integer "club_id",
|
106
|
+
create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
107
|
+
t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
|
108
|
+
t.integer "club_id", limit: 4, null: false#{unsigned_if_enabled}
|
109
109
|
end
|
110
110
|
|
111
111
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
112
112
|
|
113
|
-
create_table "employees2", primary_key: "emp_no", force:
|
113
|
+
create_table "employees2", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade, renamed_from: 'employees' do |t|
|
114
114
|
t.date "birth_date", null: false
|
115
115
|
t.string "first_name", limit: 14, null: false
|
116
116
|
t.string "last_name", limit: 16, null: false
|
@@ -118,17 +118,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
118
118
|
t.date "hire_date", null: false
|
119
119
|
end
|
120
120
|
|
121
|
-
create_table "salaries", id: false, force:
|
122
|
-
t.integer "emp_no", null: false
|
123
|
-
t.integer "salary", null: false
|
124
|
-
t.date "from_date",
|
125
|
-
t.date "to_date",
|
121
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
122
|
+
t.integer "emp_no", limit: 4, null: false
|
123
|
+
t.integer "salary", limit: 4, null: false
|
124
|
+
t.date "from_date", null: false
|
125
|
+
t.date "to_date", null: false
|
126
126
|
end
|
127
127
|
|
128
128
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
129
129
|
|
130
|
-
create_table "titles", id: false, force:
|
131
|
-
t.integer "emp_no",
|
130
|
+
create_table "titles", id: false, force: :cascade do |t|
|
131
|
+
t.integer "emp_no", limit: 4, null: false
|
132
132
|
t.string "title", limit: 50, null: false
|
133
133
|
t.date "from_date", null: false
|
134
134
|
t.date "to_date"
|
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when with ignore tables option (same)' do
|
3
3
|
let(:current_schema) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "employees", primary_key: "emp_no", force:
|
5
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
6
|
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
8
8
|
t.string "last_name", limit: 16, null: false
|
@@ -10,7 +10,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
10
10
|
t.date "hire_date", null: false
|
11
11
|
end
|
12
12
|
|
13
|
-
create_table "salaries", id: false, force:
|
13
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
14
14
|
t.integer "emp_no", null: false
|
15
15
|
t.integer "salary", null: false
|
16
16
|
t.date "from_date", null: false
|
@@ -23,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
23
23
|
|
24
24
|
let(:dsl) {
|
25
25
|
<<-RUBY
|
26
|
-
create_table "employees", primary_key: "emp_no", force:
|
26
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
27
27
|
t.date "birth_date", null: false
|
28
28
|
t.string "first_name", limit: 14, null: false
|
29
29
|
t.string "last_name", limit: 16, null: false
|
@@ -31,7 +31,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
31
31
|
t.date "hire_date", null: false
|
32
32
|
end
|
33
33
|
|
34
|
-
create_table "salaries", id: false, force:
|
34
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
35
35
|
t.integer "emp_no", null: false
|
36
36
|
t.integer "salary", null: false
|
37
37
|
t.date "from_date", null: false
|
@@ -44,7 +44,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
44
44
|
|
45
45
|
let(:expected_dsl) {
|
46
46
|
<<-RUBY
|
47
|
-
create_table "employees", primary_key: "emp_no", force:
|
47
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
48
48
|
t.date "birth_date", null: false
|
49
49
|
t.string "first_name", limit: 14, null: false
|
50
50
|
t.string "last_name", limit: 16, null: false
|
@@ -69,7 +69,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
69
69
|
context 'when with ignore tables option (differ)' do
|
70
70
|
let(:current_schema) {
|
71
71
|
<<-RUBY
|
72
|
-
create_table "employees", primary_key: "emp_no", force:
|
72
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
73
73
|
t.date "birth_date", null: false
|
74
74
|
t.string "first_name", limit: 14, null: false
|
75
75
|
t.string "last_name", limit: 16, null: false
|
@@ -77,7 +77,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
77
77
|
t.date "hire_date", null: false
|
78
78
|
end
|
79
79
|
|
80
|
-
create_table "salaries", id: false, force:
|
80
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
81
81
|
t.integer "emp_no", null: false
|
82
82
|
t.integer "salary", null: false
|
83
83
|
t.date "from_date", null: false
|
@@ -90,7 +90,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
90
90
|
|
91
91
|
let(:dsl) {
|
92
92
|
<<-RUBY
|
93
|
-
create_table "employees", primary_key: "emp_no", force:
|
93
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
94
94
|
t.date "birth_date", null: false
|
95
95
|
t.string "first_name", limit: 15, null: false
|
96
96
|
t.string "last_name", limit: 16, null: false
|
@@ -98,7 +98,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
98
98
|
t.date "hire_date", null: false
|
99
99
|
end
|
100
100
|
|
101
|
-
create_table "salaries", id: false, force:
|
101
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
102
102
|
t.integer "emp_no", null: false
|
103
103
|
t.integer "salary", null: false
|
104
104
|
t.date "from_date", null: false
|
@@ -111,7 +111,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
111
111
|
|
112
112
|
let(:before_dsl) {
|
113
113
|
<<-RUBY
|
114
|
-
create_table "employees", primary_key: "emp_no", force:
|
114
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
115
115
|
t.date "birth_date", null: false
|
116
116
|
t.string "first_name", limit: 14, null: false
|
117
117
|
t.string "last_name", limit: 16, null: false
|
@@ -123,7 +123,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
123
123
|
|
124
124
|
let(:after_dsl) {
|
125
125
|
<<-RUBY
|
126
|
-
create_table "employees", primary_key: "emp_no", force:
|
126
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
127
127
|
t.date "birth_date", null: false
|
128
128
|
t.string "first_name", limit: 15, null: false
|
129
129
|
t.string "last_name", limit: 16, null: false
|
@@ -145,7 +145,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
145
145
|
}
|
146
146
|
|
147
147
|
it {
|
148
|
-
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true,
|
148
|
+
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
149
149
|
expect(delta.differ?).to be_truthy
|
150
150
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
151
151
|
change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :unsigned=>false})
|
@@ -3,19 +3,19 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
3
3
|
let(:actual_dsl) { '' }
|
4
4
|
let(:dsl) {
|
5
5
|
<<-RUBY
|
6
|
-
create_table "clubs", force:
|
6
|
+
create_table "clubs", force: :cascade do |t|
|
7
7
|
t.string "name", default: "", null: false
|
8
8
|
end
|
9
9
|
|
10
10
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
11
11
|
|
12
|
-
create_table "departments", primary_key: "dept_no", force:
|
12
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
13
|
t.string "dept_name", limit: 40, null: false
|
14
14
|
end
|
15
15
|
|
16
16
|
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
17
17
|
|
18
|
-
create_table "dept_emp", id: false, force:
|
18
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
19
19
|
t.integer "emp_no", null: false
|
20
20
|
t.string "dept_no", limit: 4, null: false
|
21
21
|
t.date "from_date", null: false
|
@@ -25,7 +25,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
25
25
|
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
26
26
|
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
27
27
|
|
28
|
-
create_table "dept_manager", id: false, force:
|
28
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
29
29
|
t.string "dept_no", limit: 4, null: false
|
30
30
|
t.integer "emp_no", null: false
|
31
31
|
t.date "from_date", null: false
|
@@ -35,14 +35,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
35
35
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
36
36
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
37
37
|
|
38
|
-
create_table "employee_clubs", force:
|
39
|
-
t.integer "emp_no", null: false
|
40
|
-
t.integer "club_id", null: false
|
38
|
+
create_table "employee_clubs", force: :cascade do |t|
|
39
|
+
t.integer "emp_no", null: false#{unsigned_if_enabled}
|
40
|
+
t.integer "club_id", null: false#{unsigned_if_enabled}
|
41
41
|
end
|
42
42
|
|
43
43
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
44
44
|
|
45
|
-
create_table "employees", primary_key: "emp_no", force:
|
45
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
46
46
|
t.date "birth_date", null: false
|
47
47
|
t.string "first_name", limit: 14, null: false
|
48
48
|
t.string "last_name", limit: 16, null: false
|
@@ -50,7 +50,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
50
50
|
t.date "hire_date", null: false
|
51
51
|
end
|
52
52
|
|
53
|
-
create_table "salaries", id: false, force:
|
53
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
54
54
|
t.integer "emp_no", null: false
|
55
55
|
t.integer "salary", null: false
|
56
56
|
t.date "from_date", null: false
|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
59
59
|
|
60
60
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
61
61
|
|
62
|
-
create_table "titles", id: false, force:
|
62
|
+
create_table "titles", id: false, force: :cascade do |t|
|
63
63
|
t.integer "emp_no", null: false
|
64
64
|
t.string "title", limit: 50, null: false
|
65
65
|
t.date "from_date", null: false
|
@@ -72,20 +72,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
72
72
|
|
73
73
|
let(:expected_dsl) {
|
74
74
|
<<-RUBY
|
75
|
-
create_table "clubs", force:
|
76
|
-
t.string "name", default: "", null: false
|
75
|
+
create_table "clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
76
|
+
t.string "name", limit: 255, default: "", null: false
|
77
77
|
end
|
78
78
|
|
79
79
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
80
80
|
|
81
|
-
create_table "departments", primary_key: "dept_no", force:
|
81
|
+
create_table "departments", primary_key: "dept_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
82
82
|
t.string "dept_name", limit: 40, null: false
|
83
83
|
end
|
84
84
|
|
85
85
|
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
86
86
|
|
87
|
-
create_table "dept_emp", id: false, force:
|
88
|
-
t.integer "emp_no",
|
87
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
88
|
+
t.integer "emp_no", limit: 4, null: false
|
89
89
|
t.string "dept_no", limit: 4, null: false
|
90
90
|
t.date "from_date", null: false
|
91
91
|
t.date "to_date", null: false
|
@@ -94,9 +94,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
94
94
|
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
95
95
|
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
96
96
|
|
97
|
-
create_table "dept_manager", id: false, force:
|
97
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
98
98
|
t.string "dept_no", limit: 4, null: false
|
99
|
-
t.integer "emp_no",
|
99
|
+
t.integer "emp_no", limit: 4, null: false
|
100
100
|
t.date "from_date", null: false
|
101
101
|
t.date "to_date", null: false
|
102
102
|
end
|
@@ -104,14 +104,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
104
104
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
105
105
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
106
106
|
|
107
|
-
create_table "employee_clubs", force:
|
108
|
-
t.integer "emp_no",
|
109
|
-
t.integer "club_id",
|
107
|
+
create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
108
|
+
t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
|
109
|
+
t.integer "club_id", limit: 4, null: false#{unsigned_if_enabled}
|
110
110
|
end
|
111
111
|
|
112
112
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
113
113
|
|
114
|
-
create_table "employees", primary_key: "emp_no", force:
|
114
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
115
115
|
t.date "birth_date", null: false
|
116
116
|
t.string "first_name", limit: 14, null: false
|
117
117
|
t.string "last_name", limit: 16, null: false
|
@@ -119,25 +119,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
119
119
|
t.date "hire_date", null: false
|
120
120
|
end
|
121
121
|
|
122
|
-
create_table "post", id: false, force:
|
123
|
-
t.integer "id"
|
122
|
+
create_table "post", id: false, force: :cascade do |t|
|
123
|
+
t.integer "id", limit: 4
|
124
124
|
end
|
125
125
|
|
126
|
-
create_table "pre", id: false, force:
|
127
|
-
t.integer "id"
|
126
|
+
create_table "pre", id: false, force: :cascade do |t|
|
127
|
+
t.integer "id", limit: 4
|
128
128
|
end
|
129
129
|
|
130
|
-
create_table "salaries", id: false, force:
|
131
|
-
t.integer "emp_no", null: false
|
132
|
-
t.integer "salary", null: false
|
133
|
-
t.date "from_date",
|
134
|
-
t.date "to_date",
|
130
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
131
|
+
t.integer "emp_no", limit: 4, null: false
|
132
|
+
t.integer "salary", limit: 4, null: false
|
133
|
+
t.date "from_date", null: false
|
134
|
+
t.date "to_date", null: false
|
135
135
|
end
|
136
136
|
|
137
137
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
138
138
|
|
139
|
-
create_table "titles", id: false, force:
|
140
|
-
t.integer "emp_no",
|
139
|
+
create_table "titles", id: false, force: :cascade do |t|
|
140
|
+
t.integer "emp_no", limit: 4, null: false
|
141
141
|
t.string "title", limit: 50, null: false
|
142
142
|
t.date "from_date", null: false
|
143
143
|
t.date "to_date"
|
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when with tables option (same)' do
|
3
3
|
let(:current_schema) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "employees", primary_key: "emp_no", force:
|
5
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
6
|
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
8
8
|
t.string "last_name", limit: 16, null: false
|
@@ -10,7 +10,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
10
10
|
t.date "hire_date", null: false
|
11
11
|
end
|
12
12
|
|
13
|
-
create_table "salaries", id: false, force:
|
13
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
14
14
|
t.integer "emp_no", null: false
|
15
15
|
t.integer "salary", null: false
|
16
16
|
t.date "from_date", null: false
|
@@ -23,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
23
23
|
|
24
24
|
let(:dsl) {
|
25
25
|
<<-RUBY
|
26
|
-
create_table "employees", primary_key: "emp_no", force:
|
26
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
27
27
|
t.date "birth_date", null: false
|
28
28
|
t.string "first_name", limit: 14, null: false
|
29
29
|
t.string "last_name", limit: 16, null: false
|
@@ -31,7 +31,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
31
31
|
t.date "hire_date", null: false
|
32
32
|
end
|
33
33
|
|
34
|
-
create_table "salaries", id: false, force:
|
34
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
35
35
|
t.integer "emp_no", null: false
|
36
36
|
t.integer "salary", null: false
|
37
37
|
t.date "from_date", null: false
|
@@ -44,7 +44,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
44
44
|
|
45
45
|
let(:expected_dsl) {
|
46
46
|
<<-RUBY
|
47
|
-
create_table "employees", primary_key: "emp_no", force:
|
47
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
48
48
|
t.date "birth_date", null: false
|
49
49
|
t.string "first_name", limit: 14, null: false
|
50
50
|
t.string "last_name", limit: 16, null: false
|
@@ -69,7 +69,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
69
69
|
context 'when with tables option (differ)' do
|
70
70
|
let(:current_schema) {
|
71
71
|
<<-RUBY
|
72
|
-
create_table "employees", primary_key: "emp_no", force:
|
72
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
73
73
|
t.date "birth_date", null: false
|
74
74
|
t.string "first_name", limit: 14, null: false
|
75
75
|
t.string "last_name", limit: 16, null: false
|
@@ -77,7 +77,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
77
77
|
t.date "hire_date", null: false
|
78
78
|
end
|
79
79
|
|
80
|
-
create_table "salaries", id: false, force:
|
80
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
81
81
|
t.integer "emp_no", null: false
|
82
82
|
t.integer "salary", null: false
|
83
83
|
t.date "from_date", null: false
|
@@ -90,7 +90,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
90
90
|
|
91
91
|
let(:dsl) {
|
92
92
|
<<-RUBY
|
93
|
-
create_table "employees", primary_key: "emp_no", force:
|
93
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
94
94
|
t.date "birth_date", null: false
|
95
95
|
t.string "first_name", limit: 15, null: false
|
96
96
|
t.string "last_name", limit: 16, null: false
|
@@ -98,7 +98,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
98
98
|
t.date "hire_date", null: false
|
99
99
|
end
|
100
100
|
|
101
|
-
create_table "salaries", id: false, force:
|
101
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
102
102
|
t.integer "emp_no", null: false
|
103
103
|
t.integer "salary", null: false
|
104
104
|
t.date "from_date", null: false
|
@@ -111,7 +111,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
111
111
|
|
112
112
|
let(:before_dsl) {
|
113
113
|
<<-RUBY
|
114
|
-
create_table "employees", primary_key: "emp_no", force:
|
114
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
115
115
|
t.date "birth_date", null: false
|
116
116
|
t.string "first_name", limit: 14, null: false
|
117
117
|
t.string "last_name", limit: 16, null: false
|
@@ -123,7 +123,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
123
123
|
|
124
124
|
let(:after_dsl) {
|
125
125
|
<<-RUBY
|
126
|
-
create_table "employees", primary_key: "emp_no", force:
|
126
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
127
127
|
t.date "birth_date", null: false
|
128
128
|
t.string "first_name", limit: 15, null: false
|
129
129
|
t.string "last_name", limit: 16, null: false
|
@@ -145,7 +145,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
145
145
|
}
|
146
146
|
|
147
147
|
it {
|
148
|
-
delta = Ridgepole::Client.diff(current_schema, dsl, tables: ['employees'], reverse: true,
|
148
|
+
delta = Ridgepole::Client.diff(current_schema, dsl, tables: ['employees'], reverse: true, enable_mysql_awesome: true)
|
149
149
|
expect(delta.differ?).to be_truthy
|
150
150
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
151
151
|
change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :unsigned=>false})
|
@@ -2,43 +2,43 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change fk' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "parent", force:
|
5
|
+
create_table "parent", force: :cascade do |t|
|
6
6
|
end
|
7
7
|
|
8
|
-
create_table "child", force:
|
9
|
-
t.integer "parent_id"
|
8
|
+
create_table "child", force: :cascade do |t|
|
9
|
+
t.integer "parent_id"#{unsigned_if_enabled}
|
10
10
|
end
|
11
11
|
|
12
12
|
add_index "child", ["parent_id"], name: "par_ind", using: :btree
|
13
13
|
|
14
|
-
add_foreign_key "child", "parent", name: "child_ibfk_1",
|
14
|
+
add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
|
15
15
|
RUBY
|
16
16
|
}
|
17
17
|
|
18
18
|
let(:sorted_actual_dsl) {
|
19
19
|
<<-RUBY
|
20
|
-
create_table "child", force:
|
21
|
-
t.integer "parent_id",
|
20
|
+
create_table "child"#{unsigned_if_enabled}, force: :cascade do |t|
|
21
|
+
t.integer "parent_id", limit: 4#{unsigned_if_enabled}
|
22
22
|
end
|
23
23
|
|
24
24
|
add_index "child", ["parent_id"], name: "par_ind", using: :btree
|
25
25
|
|
26
|
-
create_table "parent", force:
|
26
|
+
create_table "parent"#{unsigned_if_enabled}, force: :cascade do |t|
|
27
27
|
end
|
28
28
|
|
29
|
-
add_foreign_key "child", "parent", name: "child_ibfk_1",
|
29
|
+
add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
|
30
30
|
RUBY
|
31
31
|
}
|
32
32
|
|
33
33
|
let(:expected_dsl) {
|
34
34
|
<<-RUBY
|
35
|
-
create_table "child", force:
|
36
|
-
t.integer "parent_id",
|
35
|
+
create_table "child"#{unsigned_if_enabled}, force: :cascade do |t|
|
36
|
+
t.integer "parent_id", limit: 4#{unsigned_if_enabled}
|
37
37
|
end
|
38
38
|
|
39
39
|
add_index "child", ["parent_id"], name: "par_ind", using: :btree
|
40
40
|
|
41
|
-
create_table "parent", force:
|
41
|
+
create_table "parent"#{unsigned_if_enabled}, force: :cascade do |t|
|
42
42
|
end
|
43
43
|
|
44
44
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|