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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -50
  3. data/bin/ridgepole +8 -18
  4. data/lib/ridgepole/client.rb +10 -16
  5. data/lib/ridgepole/delta.rb +57 -19
  6. data/lib/ridgepole/diff.rb +45 -14
  7. data/lib/ridgepole/dsl_parser.rb +38 -8
  8. data/lib/ridgepole/execute_expander.rb +0 -29
  9. data/lib/ridgepole/ext/mysql_awesome.rb +1 -5
  10. data/lib/ridgepole/version.rb +1 -1
  11. data/lib/ridgepole.rb +10 -2
  12. data/ridgepole.gemspec +3 -8
  13. data/spec/bigint_pk/bigint_pkspec.rb +2 -2
  14. data/spec/cli/ridgepole_spec.rb +3 -5
  15. data/spec/collation/collation_spec.rb +35 -35
  16. data/spec/diff/diff2_spec.rb +18 -18
  17. data/spec/diff/diff_spec.rb +18 -18
  18. data/spec/dump/dump_class_method_spec.rb +18 -18
  19. data/spec/dump/dump_some_tables_spec.rb +12 -12
  20. data/spec/dump/dump_spec.rb +18 -18
  21. data/spec/dump/dump_without_table_options_spec.rb +6 -6
  22. data/spec/migrate/check_orphan_index_spec.rb +8 -8
  23. data/spec/migrate/migrate_add_column2_spec.rb +15 -15
  24. data/spec/migrate/migrate_add_column_spec.rb +40 -40
  25. data/spec/migrate/migrate_change_column2_spec.rb +5 -5
  26. data/spec/migrate/migrate_change_column3_spec.rb +26 -26
  27. data/spec/migrate/migrate_change_column_float_spec.rb +7 -7
  28. data/spec/migrate/migrate_change_column_spec.rb +42 -42
  29. data/spec/migrate/migrate_change_index2_spec.rb +13 -13
  30. data/spec/migrate/migrate_change_index3_spec.rb +26 -26
  31. data/spec/migrate/migrate_change_index4_spec.rb +28 -28
  32. data/spec/migrate/migrate_change_index_spec.rb +46 -46
  33. data/spec/migrate/migrate_change_table_option_spec.rb +2 -2
  34. data/spec/migrate/migrate_create_index_spec.rb +18 -18
  35. data/spec/migrate/migrate_create_table_spec.rb +18 -18
  36. data/spec/migrate/migrate_create_table_with_options_spec.rb +3 -3
  37. data/spec/migrate/migrate_drop_column_and_index_2_spec.rb +35 -35
  38. data/spec/migrate/migrate_drop_column_and_index_spec.rb +33 -33
  39. data/spec/migrate/migrate_drop_column_spec.rb +36 -36
  40. data/spec/migrate/migrate_drop_index_spec.rb +18 -18
  41. data/spec/migrate/migrate_drop_table_spec.rb +24 -24
  42. data/spec/migrate/migrate_duplicate_index_spec.rb +1 -1
  43. data/spec/migrate/migrate_duplicate_table_spec.rb +2 -2
  44. data/spec/migrate/migrate_empty_spec.rb +18 -18
  45. data/spec/migrate/migrate_execute_spec.rb +58 -49
  46. data/spec/migrate/migrate_merge_mode_spec.rb +38 -38
  47. data/spec/migrate/migrate_noop_spec.rb +40 -40
  48. data/spec/migrate/migrate_rename_column_spec.rb +37 -37
  49. data/spec/migrate/migrate_rename_table_spec.rb +39 -39
  50. data/spec/migrate/migrate_same_default_null_spec.rb +4 -4
  51. data/spec/migrate/migrate_same_spec.rb +18 -18
  52. data/spec/migrate/migrate_script_error_spec.rb +8 -8
  53. data/spec/migrate/migrate_skip_rename_column_spec.rb +36 -36
  54. data/spec/migrate/migrate_skip_rename_table_spec.rb +36 -36
  55. data/spec/migrate/migrate_with_ignore_tables_spec.rb +12 -12
  56. data/spec/migrate/migrate_with_pre_post_query_spec.rb +32 -32
  57. data/spec/migrate/migrate_with_tables_spec.rb +12 -12
  58. data/spec/migrate_0/migrate_change_fk_spec.rb +11 -11
  59. data/spec/migrate_0/migrate_create_fk_spec.rb +29 -30
  60. data/spec/migrate_0/migrate_drop_fk_spec.rb +22 -23
  61. data/spec/spec_helper.rb +24 -2
  62. metadata +10 -89
  63. data/lib/ridgepole/ext/foreign_key.rb +0 -121
  64. data/spec/0_diff/dump_disable_unsigned_spec.rb +0 -75
  65. data/spec/comment/comment_spec.rb +0 -179
  66. data/spec/migrate/migrate_same_default_unsigned_spec.rb +0 -63
  67. data/spec/~pkdump/pkdump_spec.rb +0 -67
@@ -2,20 +2,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when marge table' do
3
3
  let(:actual_dsl) {
4
4
  <<-RUBY
5
- create_table "clubs", force: true do |t|
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: true do |t|
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: true do |t|
18
- t.integer "emp_no", null: false
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: true do |t|
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", null: false
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: true do |t|
38
- t.integer "emp_no", null: false, unsigned: true
39
- t.integer "club_id", null: false, unsigned: true
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 "employees", primary_key: "emp_no", force: true do |t|
44
+ create_table "employees", 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: true 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
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: true do |t|
62
- t.integer "emp_no", null: false
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,24 +71,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
71
71
 
72
72
  let(:expected_dsl) {
73
73
  <<-RUBY
74
- create_table "clubs", force: true do |t|
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 "clubs2", force: true do |t|
81
- t.string "name2", default: "", null: false
80
+ create_table "clubs2"#{unsigned_if_enabled}, force: :cascade do |t|
81
+ t.string "name2", limit: 255, default: "", null: false
82
82
  end
83
83
 
84
- create_table "departments", primary_key: "dept_no", force: true do |t|
84
+ create_table "departments", primary_key: "dept_no"#{unsigned_if_enabled}, force: :cascade do |t|
85
85
  t.string "dept_name", limit: 40, null: false
86
86
  end
87
87
 
88
88
  add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
89
89
 
90
- create_table "dept_emp", id: false, force: true do |t|
91
- t.integer "emp_no", null: false
90
+ create_table "dept_emp", id: false, force: :cascade do |t|
91
+ t.integer "emp_no", limit: 4, null: false
92
92
  t.string "dept_no", limit: 4, null: false
93
93
  t.date "from_date", null: false
94
94
  t.date "to_date", null: false
@@ -97,9 +97,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
97
97
  add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
98
98
  add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
99
99
 
100
- create_table "dept_manager", id: false, force: true do |t|
100
+ create_table "dept_manager", id: false, force: :cascade do |t|
101
101
  t.string "dept_no", limit: 4, null: false
102
- t.integer "emp_no", null: false
102
+ t.integer "emp_no", limit: 4, null: false
103
103
  t.date "from_date", null: false
104
104
  t.date "to_date", null: false
105
105
  end
@@ -107,14 +107,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
107
107
  add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
108
108
  add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
109
109
 
110
- create_table "employee_clubs", force: true do |t|
111
- t.integer "emp_no", null: false, unsigned: true
112
- t.integer "club_id", null: false, unsigned: true
110
+ create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
111
+ t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
112
+ t.integer "club_id", limit: 4, null: false#{unsigned_if_enabled}
113
113
  end
114
114
 
115
115
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
116
116
 
117
- create_table "employees", primary_key: "emp_no", force: true do |t|
117
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
118
118
  t.date "birth_date", null: false
119
119
  t.string "first_name", limit: 14, null: false
120
120
  t.string "last_name", limit: 16, null: false
@@ -122,17 +122,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
122
122
  t.date "hire_date", null: false
123
123
  end
124
124
 
125
- create_table "salaries", id: false, force: true do |t|
126
- t.integer "emp_no", null: false
127
- t.integer "salary", null: false
128
- t.date "from_date", null: false
129
- t.date "to_date", null: false
125
+ create_table "salaries", id: false, force: :cascade do |t|
126
+ t.integer "emp_no", limit: 4, null: false
127
+ t.integer "salary", limit: 4, null: false
128
+ t.date "from_date", null: false
129
+ t.date "to_date", null: false
130
130
  end
131
131
 
132
132
  add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
133
133
 
134
- create_table "titles", id: false, force: true do |t|
135
- t.integer "emp_no", null: false
134
+ create_table "titles", id: false, force: :cascade do |t|
135
+ t.integer "emp_no", limit: 4, null: false
136
136
  t.string "title", limit: 50, null: false
137
137
  t.date "from_date", null: false
138
138
  t.date "to_date"
@@ -3,19 +3,19 @@ describe 'Ridgepole::Client#diff -> migrate' do
3
3
  let(:actual_dsl) { '' }
4
4
  let(:expected_dsl) {
5
5
  <<-RUBY
6
- create_table "clubs", force: true do |t|
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: true do |t|
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: true do |t|
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: true do |t|
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: true do |t|
38
+ create_table "employee_clubs", force: :cascade do |t|
39
39
  t.integer "emp_no", null: false, unsigned: true
40
40
  t.integer "club_id", null: false, unsigned: true
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: true do |t|
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: true do |t|
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: true do |t|
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
@@ -82,22 +82,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
82
82
  sql = sql.each_line.map {|i| i.strip }.join("\n")
83
83
 
84
84
  expect(sql).to eq <<-SQL.strip_heredoc.strip
85
- CREATE TABLE `clubs` (`id` int unsigned auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) ENGINE=InnoDB
85
+ CREATE TABLE `clubs` (`id` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `name` varchar(255) DEFAULT '' NOT NULL) ENGINE=InnoDB
86
86
  CREATE UNIQUE INDEX `idx_name` USING btree ON `clubs` (`name`)
87
- CREATE TABLE `departments` (`dept_no` int unsigned auto_increment PRIMARY KEY, `dept_name` varchar(40) NOT NULL) ENGINE=InnoDB
87
+ CREATE TABLE `departments` (`dept_no` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `dept_name` varchar(40) NOT NULL) ENGINE=InnoDB
88
88
  CREATE UNIQUE INDEX `dept_name` USING btree ON `departments` (`dept_name`)
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) ENGINE=InnoDB
89
+ CREATE TABLE `dept_emp` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
90
90
  CREATE INDEX `dept_no` USING btree ON `dept_emp` (`dept_no`)
91
91
  CREATE INDEX `emp_no` USING btree ON `dept_emp` (`emp_no`)
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) ENGINE=InnoDB
92
+ CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) 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` int unsigned auto_increment PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) ENGINE=InnoDB
95
+ CREATE TABLE `employee_clubs` (`id` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `emp_no` #{if_mysql_awesome_enabled('int unsigned', 'int(11)')} NOT NULL, `club_id` #{if_mysql_awesome_enabled('int unsigned', 'int(11)')} NOT NULL) 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` int unsigned 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) ENGINE=InnoDB
98
- CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
97
+ CREATE TABLE `employees` (`emp_no` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) 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) ENGINE=InnoDB
98
+ CREATE TABLE `salaries` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `salary` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
99
99
  CREATE INDEX `emp_no` USING btree ON `salaries` (`emp_no`)
100
- CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) ENGINE=InnoDB
100
+ CREATE TABLE `titles` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) ENGINE=InnoDB
101
101
  CREATE INDEX `emp_no` USING btree ON `titles` (`emp_no`)
102
102
  SQL
103
103
  }
@@ -112,20 +112,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
112
112
  sql = sql.each_line.map {|i| i.strip }.join("\n")
113
113
 
114
114
  expect(sql).to eq <<-SQL.strip_heredoc.strip
115
- CREATE TABLE `clubs` (`id` int unsigned auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) ENGINE=InnoDB
115
+ CREATE TABLE `clubs` (`id` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `name` varchar(255) DEFAULT '' NOT NULL) ENGINE=InnoDB
116
116
  ALTER TABLE `clubs` ADD UNIQUE INDEX idx_name (`name`)
117
- CREATE TABLE `departments` (`dept_no` int unsigned auto_increment PRIMARY KEY, `dept_name` varchar(40) NOT NULL) ENGINE=InnoDB
117
+ CREATE TABLE `departments` (`dept_no` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `dept_name` varchar(40) NOT NULL) ENGINE=InnoDB
118
118
  ALTER TABLE `departments` ADD UNIQUE INDEX dept_name (`dept_name`)
119
- 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) ENGINE=InnoDB
119
+ CREATE TABLE `dept_emp` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
120
120
  ALTER TABLE `dept_emp` ADD INDEX dept_no (`dept_no`), ADD INDEX emp_no (`emp_no`)
121
- 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) ENGINE=InnoDB
121
+ CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
122
122
  ALTER TABLE `dept_manager` ADD INDEX dept_no (`dept_no`), ADD INDEX emp_no (`emp_no`)
123
- CREATE TABLE `employee_clubs` (`id` int unsigned auto_increment PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) ENGINE=InnoDB
123
+ CREATE TABLE `employee_clubs` (`id` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `emp_no` #{if_mysql_awesome_enabled('int unsigned', 'int(11)')} NOT NULL, `club_id` #{if_mysql_awesome_enabled('int unsigned', 'int(11)')} NOT NULL) ENGINE=InnoDB
124
124
  ALTER TABLE `employee_clubs` ADD INDEX idx_emp_no_club_id (`emp_no`, `club_id`)
125
- CREATE TABLE `employees` (`emp_no` int unsigned 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) ENGINE=InnoDB
126
- CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
125
+ CREATE TABLE `employees` (`emp_no` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) 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) ENGINE=InnoDB
126
+ CREATE TABLE `salaries` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `salary` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
127
127
  ALTER TABLE `salaries` ADD INDEX emp_no (`emp_no`)
128
- CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) ENGINE=InnoDB
128
+ CREATE TABLE `titles` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) ENGINE=InnoDB
129
129
  ALTER TABLE `titles` ADD INDEX emp_no (`emp_no`)
130
130
  SQL
131
131
  }
@@ -135,19 +135,19 @@ describe 'Ridgepole::Client#diff -> migrate' do
135
135
  let(:actual_dsl) { '' }
136
136
  let(:expected_dsl) {
137
137
  <<-RUBY
138
- create_table "clubs", force: true do |t|
138
+ create_table "clubs", force: :cascade do |t|
139
139
  t.string "name", default: "", null: false
140
140
  end
141
141
 
142
142
  add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
143
143
 
144
- create_table "departments", primary_key: "dept_no", force: true do |t|
144
+ create_table "departments", primary_key: "dept_no", force: :cascade do |t|
145
145
  t.string "dept_name", limit: 40, null: false
146
146
  end
147
147
 
148
148
  add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
149
149
 
150
- create_table "dept_emp", id: false, force: true do |t|
150
+ create_table "dept_emp", id: false, force: :cascade do |t|
151
151
  t.integer "emp_no", null: false
152
152
  t.string "dept_no", limit: 4, null: false
153
153
  t.date "from_date", null: false
@@ -157,7 +157,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
157
157
  add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
158
158
  add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
159
159
 
160
- create_table "dept_manager", id: false, force: true do |t|
160
+ create_table "dept_manager", id: false, force: :cascade do |t|
161
161
  t.string "dept_no", limit: 4, null: false
162
162
  t.integer "emp_no", limit: 4, null: false
163
163
  t.date "from_date", null: false
@@ -167,14 +167,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
167
167
  add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
168
168
  add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
169
169
 
170
- create_table "employee_clubs", force: true do |t|
170
+ create_table "employee_clubs", force: :cascade do |t|
171
171
  t.integer "emp_no", null: false, unsigned: true
172
172
  t.integer "club_id", null: false, unsigned: true
173
173
  end
174
174
 
175
175
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
176
176
 
177
- create_table "employees", primary_key: "emp_no", force: true do |t|
177
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
178
178
  t.date "birth_date", null: false
179
179
  t.string "first_name", limit: 14, null: false
180
180
  t.string "last_name", limit: 16, null: false
@@ -182,7 +182,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
182
182
  t.date "hire_date", null: false
183
183
  end
184
184
 
185
- create_table "salaries", id: false, force: true do |t|
185
+ create_table "salaries", id: false, force: :cascade do |t|
186
186
  t.integer "emp_no", null: false
187
187
  t.integer "salary", null: false
188
188
  t.date "from_date", null: false
@@ -191,7 +191,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
191
191
 
192
192
  add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
193
193
 
194
- create_table "titles", id: false, force: true do |t|
194
+ create_table "titles", id: false, force: :cascade do |t|
195
195
  t.integer "emp_no", null: false
196
196
  t.string "title", limit: 50, null: false
197
197
  t.date "from_date", null: false
@@ -214,22 +214,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
214
214
  sql = sql.each_line.map {|i| i.strip }.join("\n")
215
215
 
216
216
  expect(sql).to eq <<-SQL.strip_heredoc.strip
217
- CREATE TABLE `clubs` (`id` int unsigned auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT '' NOT NULL) ENGINE=InnoDB
217
+ CREATE TABLE `clubs` (`id` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `name` varchar(255) DEFAULT '' NOT NULL) ENGINE=InnoDB
218
218
  CREATE UNIQUE INDEX `idx_name` USING btree ON `clubs` (`name`)
219
- CREATE TABLE `departments` (`dept_no` int unsigned auto_increment PRIMARY KEY, `dept_name` varchar(40) NOT NULL) ENGINE=InnoDB
219
+ CREATE TABLE `departments` (`dept_no` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `dept_name` varchar(40) NOT NULL) ENGINE=InnoDB
220
220
  CREATE UNIQUE INDEX `dept_name` USING btree ON `departments` (`dept_name`)
221
- 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) ENGINE=InnoDB
221
+ CREATE TABLE `dept_emp` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `dept_no` varchar(4) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
222
222
  CREATE INDEX `dept_no` USING btree ON `dept_emp` (`dept_no`)
223
223
  CREATE INDEX `emp_no` USING btree ON `dept_emp` (`emp_no`)
224
- 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) ENGINE=InnoDB
224
+ CREATE TABLE `dept_manager` (`dept_no` varchar(4) NOT NULL, `emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
225
225
  CREATE INDEX `dept_no` USING btree ON `dept_manager` (`dept_no`)
226
226
  CREATE INDEX `emp_no` USING btree ON `dept_manager` (`emp_no`)
227
- CREATE TABLE `employee_clubs` (`id` int unsigned auto_increment PRIMARY KEY, `emp_no` int unsigned NOT NULL, `club_id` int unsigned NOT NULL) ENGINE=InnoDB
227
+ CREATE TABLE `employee_clubs` (`id` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) auto_increment PRIMARY KEY')}, `emp_no` #{if_mysql_awesome_enabled('int unsigned', 'int(11)')} NOT NULL, `club_id` #{if_mysql_awesome_enabled('int unsigned', 'int(11)')} NOT NULL) ENGINE=InnoDB
228
228
  CREATE INDEX `idx_emp_no_club_id` USING btree ON `employee_clubs` (`emp_no`, `club_id`)
229
- CREATE TABLE `employees` (`emp_no` int unsigned 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) ENGINE=InnoDB
230
- CREATE TABLE `salaries` (`emp_no` int NOT NULL, `salary` int NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
229
+ CREATE TABLE `employees` (`emp_no` #{if_mysql_awesome_enabled('int unsigned PRIMARY KEY AUTO_INCREMENT', 'int(11) 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) ENGINE=InnoDB
230
+ CREATE TABLE `salaries` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `salary` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL) ENGINE=InnoDB
231
231
  CREATE INDEX `emp_no` USING btree ON `salaries` (`emp_no`)
232
- CREATE TABLE `titles` (`emp_no` int NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) ENGINE=InnoDB
232
+ CREATE TABLE `titles` (`emp_no` #{if_mysql_awesome_enabled('int', 'int(11)')} NOT NULL, `title` varchar(50) NOT NULL, `from_date` date NOT NULL, `to_date` date) ENGINE=InnoDB
233
233
  CREATE INDEX `emp_no` USING btree ON `titles` (`emp_no`)
234
234
  SQL
235
235
  }
@@ -2,20 +2,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when rename column' do
3
3
  let(:actual_dsl) {
4
4
  <<-RUBY
5
- create_table "clubs", force: true do |t|
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: true do |t|
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: true do |t|
18
- t.integer "emp_no", null: false
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: true do |t|
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", null: false
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: true do |t|
38
- t.integer "emp_no", null: false, unsigned: true
39
- t.integer "club_id", null: false, unsigned: true
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 "employees", primary_key: "emp_no", force: true do |t|
44
+ create_table "employees", 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: true 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
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: true do |t|
62
- t.integer "emp_no", null: false
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: true do |t|
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: true do |t|
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: true do |t|
87
- t.integer "emp_no", null: false
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_date2", null: false, renamed_from: 'from_date'
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: true do |t|
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", null: false
98
+ t.integer "emp_no", limit: 4, null: false
99
99
  t.date "from_date", null: false
100
100
  t.date "to_date2", null: false, renamed_from: 'to_date'
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: true do |t|
107
- t.integer "emp_no", null: false, unsigned: true
108
- t.integer "club_id", null: false, unsigned: true
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 "employees", primary_key: "emp_no", force: true do |t|
113
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade 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: true do |t|
122
- t.integer "emp_no", null: false
123
- t.integer "salary", null: false
124
- t.date "from_date", null: false
125
- t.date "to_date", null: false
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: true do |t|
131
- t.integer "emp_no", null: false
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"
@@ -189,7 +189,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
189
189
 
190
190
  let(:dsl) {
191
191
  <<-RUBY
192
- create_table "employees", primary_key: "emp_no", force: true do |t|
192
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
193
193
  t.date "birth_date", null: false
194
194
  t.string "first_name", limit: 14, null: false
195
195
  t.string "last_name", limit: 16, null: false