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 drop table' do
3
3
  let(: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"
@@ -92,18 +92,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
92
92
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
93
93
  expect(delta.differ?).to be_truthy
94
94
  expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
95
- create_table("clubs", {}) do |t|
96
- t.string("name", {:default=>"", :null=>false})
95
+ create_table("clubs", {#{unsigned_if_enabled2('')}}) do |t|
96
+ t.string("name", {:limit=>255, :default=>"", :null=>false})
97
97
  end
98
98
  add_index("clubs", ["name"], {:name=>"idx_name", :unique=>true, :using=>:btree})
99
99
 
100
- create_table("employee_clubs", {}) do |t|
101
- t.integer("emp_no", {:null=>false, :unsigned=>true})
102
- t.integer("club_id", {:null=>false, :unsigned=>true})
100
+ create_table("employee_clubs", {#{unsigned_if_enabled2('')}}) do |t|
101
+ t.integer("emp_no", {:limit=>4, :null=>false#{unsigned_if_enabled2}})
102
+ t.integer("club_id", {:limit=>4, :null=>false#{unsigned_if_enabled2}})
103
103
  end
104
104
  add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
105
105
 
106
- create_table("employees", {:primary_key=>"emp_no"}) do |t|
106
+ create_table("employees", {:primary_key=>"emp_no"#{unsigned_if_enabled2}}) do |t|
107
107
  t.date("birth_date", {:null=>false})
108
108
  t.string("first_name", {:limit=>14, :null=>false})
109
109
  t.string("last_name", {:limit=>16, :null=>false})
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when index already defined' do
3
3
  let(:dsl) {
4
4
  <<-RUBY
5
- create_table "salaries", id: false, force: true do |t|
5
+ create_table "salaries", id: false, force: :cascade do |t|
6
6
  t.integer "emp_no", null: false
7
7
  t.integer "salary", null: false
8
8
  t.date "from_date", null: false
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when table already defined' do
3
3
  let(:dsl) {
4
4
  <<-RUBY
5
- create_table "employees", primary_key: "emp_no", force: true do |t|
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
@@ -12,7 +12,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
12
12
  t.date "updated_at"
13
13
  end
14
14
 
15
- create_table "employees", primary_key: "emp_no", force: true do |t|
15
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
16
16
  t.date "birth_date", null: false
17
17
  t.string "first_name", limit: 14, null: false
18
18
  t.string "last_name", limit: 16, null: false
@@ -3,20 +3,20 @@ 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|
7
- t.string "name", default: "", null: false
6
+ create_table "clubs"#{unsigned_if_enabled}, force: :cascade do |t|
7
+ t.string "name", limit: 255, 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"#{unsigned_if_enabled}, 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|
19
- t.integer "emp_no", null: false
18
+ create_table "dept_emp", id: false, force: :cascade do |t|
19
+ t.integer "emp_no", limit: 4, null: false
20
20
  t.string "dept_no", limit: 4, null: false
21
21
  t.date "from_date", null: false
22
22
  t.date "to_date", null: false
@@ -25,9 +25,9 @@ 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
- t.integer "emp_no", null: false
30
+ t.integer "emp_no", limit: 4, null: false
31
31
  t.date "from_date", null: false
32
32
  t.date "to_date", null: false
33
33
  end
@@ -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|
39
- t.integer "emp_no", null: false, unsigned: true
40
- t.integer "club_id", null: false, unsigned: true
38
+ create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
39
+ t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
40
+ t.integer "club_id", limit: 4, 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: true do |t|
45
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, 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,17 +50,17 @@ 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|
54
- t.integer "emp_no", null: false
55
- t.integer "salary", null: false
56
- t.date "from_date", null: false
57
- t.date "to_date", null: false
53
+ create_table "salaries", id: false, force: :cascade do |t|
54
+ t.integer "emp_no", limit: 4, null: false
55
+ t.integer "salary", limit: 4, null: false
56
+ t.date "from_date", null: false
57
+ t.date "to_date", null: false
58
58
  end
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|
63
- t.integer "emp_no", null: false
62
+ create_table "titles", id: false, force: :cascade do |t|
63
+ t.integer "emp_no", limit: 4, null: false
64
64
  t.string "title", limit: 50, null: false
65
65
  t.date "from_date", null: false
66
66
  t.date "to_date"
@@ -2,13 +2,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when execute' do
3
3
  let(:dsl) {
4
4
  <<-RUBY
5
- create_table "authors", force: true do |t|
6
- t.string "name", null: false
5
+ create_table "authors"#{unsigned_if_enabled}, force: :cascade do |t|
6
+ t.string "name", limit: 255, null: false
7
7
  end
8
8
 
9
- create_table "books", force: true do |t|
10
- t.string "title", null: false
11
- t.integer "author_id", null: false, unsigned: true
9
+ create_table "books"#{unsigned_if_enabled}, force: :cascade do |t|
10
+ t.string "title", limit: 255, null: false
11
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
12
12
  end
13
13
 
14
14
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
@@ -17,13 +17,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
17
17
 
18
18
  let(:dsl_with_execute) {
19
19
  <<-RUBY
20
- create_table "authors", force: true do |t|
20
+ create_table "authors", force: :cascade do |t|
21
21
  t.string "name", null: false
22
22
  end
23
23
 
24
- create_table "books", force: true do |t|
24
+ create_table "books", force: :cascade do |t|
25
25
  t.string "title", null: false
26
- t.integer "author_id", unsigned: true, null: false
26
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
27
27
  end
28
28
 
29
29
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
@@ -44,22 +44,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
44
44
 
45
45
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
46
46
  CREATE TABLE `books` (
47
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
47
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
48
48
  `title` varchar(255) NOT NULL,
49
- `author_id` int(10) unsigned NOT NULL,
49
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
50
50
  PRIMARY KEY (`id`),
51
51
  KEY `idx_author_id` (`author_id`) USING BTREE
52
52
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
53
53
  SQL
54
54
 
55
55
  delta.migrate
56
- expect(subject.dump.delete_empty_lines).to eq dsl.strip_heredoc.strip.delete_empty_lines
56
+
57
+ expect(subject.dump.delete_empty_lines).to eq (dsl + (<<-RUBY)).strip_heredoc.strip.delete_empty_lines
58
+ add_foreign_key "books", "authors", name: "fk_author"
59
+ RUBY
57
60
 
58
61
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
59
62
  CREATE TABLE `books` (
60
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
63
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
61
64
  `title` varchar(255) NOT NULL,
62
- `author_id` int(10) unsigned NOT NULL,
65
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
63
66
  PRIMARY KEY (`id`),
64
67
  KEY `idx_author_id` (`author_id`) USING BTREE,
65
68
  CONSTRAINT `fk_author` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`)
@@ -71,28 +74,29 @@ describe 'Ridgepole::Client#diff -> migrate' do
71
74
  context 'when not execute' do
72
75
  let(:dsl) {
73
76
  <<-RUBY
74
- create_table "authors", force: true do |t|
75
- t.string "name", null: false
77
+ create_table "authors"#{unsigned_if_enabled}, force: :cascade do |t|
78
+ t.string "name", limit: 255, null: false
76
79
  end
77
80
 
78
- create_table "books", force: true do |t|
79
- t.string "title", null: false
80
- t.integer "author_id", null: false, unsigned: true
81
+ create_table "books"#{unsigned_if_enabled}, force: :cascade do |t|
82
+ t.string "title", limit: 255, null: false
83
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
81
84
  end
82
85
 
83
86
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
87
+ add_foreign_key "books", "authors", name: "fk_author"
84
88
  RUBY
85
89
  }
86
90
 
87
91
  let(:dsl_with_execute) {
88
92
  <<-RUBY
89
- create_table "authors", force: true do |t|
93
+ create_table "authors", force: :cascade do |t|
90
94
  t.string "name", null: false
91
95
  end
92
96
 
93
- create_table "books", force: true do |t|
97
+ create_table "books", force: :cascade do |t|
94
98
  t.string "title", null: false
95
- t.integer "author_id", unsigned: true, null: false
99
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
96
100
  end
97
101
 
98
102
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
@@ -100,6 +104,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
100
104
  execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
101
105
  c.raw_connection.query("SELECT 1 FROM information_schema.key_column_usage WHERE TABLE_SCHEMA = '#{TEST_SCHEMA}' AND CONSTRAINT_NAME = 'fk_author' LIMIT 1").each.length.zero?
102
106
  end
107
+
108
+ add_foreign_key "books", "authors", name: "fk_author"
103
109
  RUBY
104
110
  }
105
111
 
@@ -113,9 +119,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
113
119
 
114
120
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
115
121
  CREATE TABLE `books` (
116
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
122
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
117
123
  `title` varchar(255) NOT NULL,
118
- `author_id` int(10) unsigned NOT NULL,
124
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
119
125
  PRIMARY KEY (`id`),
120
126
  KEY `idx_author_id` (`author_id`) USING BTREE,
121
127
  CONSTRAINT `fk_author` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`)
@@ -128,9 +134,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
128
134
 
129
135
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
130
136
  CREATE TABLE `books` (
131
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
137
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
132
138
  `title` varchar(255) NOT NULL,
133
- `author_id` int(10) unsigned NOT NULL,
139
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
134
140
  PRIMARY KEY (`id`),
135
141
  KEY `idx_author_id` (`author_id`) USING BTREE,
136
142
  CONSTRAINT `fk_author` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`)
@@ -142,13 +148,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
142
148
  context 'when execute (noop)' do
143
149
  let(:dsl) {
144
150
  <<-RUBY
145
- create_table "authors", force: true do |t|
146
- t.string "name", null: false
151
+ create_table "authors"#{unsigned_if_enabled}, force: :cascade do |t|
152
+ t.string "name", limit: 255, null: false
147
153
  end
148
154
 
149
- create_table "books", force: true do |t|
150
- t.string "title", null: false
151
- t.integer "author_id", null: false, unsigned: true
155
+ create_table "books"#{unsigned_if_enabled}, force: :cascade do |t|
156
+ t.string "title", limit: 255, null: false
157
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
152
158
  end
153
159
 
154
160
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
@@ -157,13 +163,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
157
163
 
158
164
  let(:dsl_with_execute) {
159
165
  <<-RUBY
160
- create_table "authors", force: true do |t|
166
+ create_table "authors", force: :cascade do |t|
161
167
  t.string "name", null: false
162
168
  end
163
169
 
164
- create_table "books", force: true do |t|
170
+ create_table "books", force: :cascade do |t|
165
171
  t.string "title", null: false
166
- t.integer "author_id", unsigned: true, null: false
172
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
167
173
  end
168
174
 
169
175
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
@@ -184,9 +190,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
184
190
 
185
191
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
186
192
  CREATE TABLE `books` (
187
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
193
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
188
194
  `title` varchar(255) NOT NULL,
189
- `author_id` int(10) unsigned NOT NULL,
195
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
190
196
  PRIMARY KEY (`id`),
191
197
  KEY `idx_author_id` (`author_id`) USING BTREE
192
198
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
@@ -200,9 +206,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
200
206
 
201
207
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
202
208
  CREATE TABLE `books` (
203
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
209
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
204
210
  `title` varchar(255) NOT NULL,
205
- `author_id` int(10) unsigned NOT NULL,
211
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
206
212
  PRIMARY KEY (`id`),
207
213
  KEY `idx_author_id` (`author_id`) USING BTREE
208
214
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
@@ -213,28 +219,29 @@ describe 'Ridgepole::Client#diff -> migrate' do
213
219
  context 'when not execute (noop)' do
214
220
  let(:dsl) {
215
221
  <<-RUBY
216
- create_table "authors", force: true do |t|
217
- t.string "name", null: false
222
+ create_table "authors"#{unsigned_if_enabled}, force: :cascade do |t|
223
+ t.string "name", limit: 255, null: false
218
224
  end
219
225
 
220
- create_table "books", force: true do |t|
221
- t.string "title", null: false
222
- t.integer "author_id", null: false, unsigned: true
226
+ create_table "books"#{unsigned_if_enabled}, force: :cascade do |t|
227
+ t.string "title", limit: 255, null: false
228
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
223
229
  end
224
230
 
225
231
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
232
+ add_foreign_key "books", "authors", name: "fk_author"
226
233
  RUBY
227
234
  }
228
235
 
229
236
  let(:dsl_with_execute) {
230
237
  <<-RUBY
231
- create_table "authors", force: true do |t|
238
+ create_table "authors", force: :cascade do |t|
232
239
  t.string "name", null: false
233
240
  end
234
241
 
235
- create_table "books", force: true do |t|
242
+ create_table "books", force: :cascade do |t|
236
243
  t.string "title", null: false
237
- t.integer "author_id", unsigned: true, null: false
244
+ t.integer "author_id", limit: 4, null: false#{unsigned_if_enabled}
238
245
  end
239
246
 
240
247
  add_index "books", ["author_id"], name: "idx_author_id", using: :btree
@@ -242,6 +249,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
242
249
  execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
243
250
  c.raw_connection.query("SELECT 1 FROM information_schema.key_column_usage WHERE TABLE_SCHEMA = '#{TEST_SCHEMA}' AND CONSTRAINT_NAME = 'fk_author' LIMIT 1").each.length.zero?
244
251
  end
252
+
253
+ add_foreign_key "books", "authors", name: "fk_author"
245
254
  RUBY
246
255
  }
247
256
 
@@ -255,9 +264,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
255
264
 
256
265
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
257
266
  CREATE TABLE `books` (
258
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
267
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
259
268
  `title` varchar(255) NOT NULL,
260
- `author_id` int(10) unsigned NOT NULL,
269
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
261
270
  PRIMARY KEY (`id`),
262
271
  KEY `idx_author_id` (`author_id`) USING BTREE,
263
272
  CONSTRAINT `fk_author` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`)
@@ -272,9 +281,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
272
281
 
273
282
  expect(show_create_table(:books).strip).to eq <<-SQL.strip_heredoc.strip
274
283
  CREATE TABLE `books` (
275
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
284
+ `id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL AUTO_INCREMENT,
276
285
  `title` varchar(255) NOT NULL,
277
- `author_id` int(10) unsigned NOT NULL,
286
+ `author_id` #{if_mysql_awesome_enabled('int(10) unsigned', 'int(11)')} NOT NULL,
278
287
  PRIMARY KEY (`id`),
279
288
  KEY `idx_author_id` (`author_id`) USING BTREE,
280
289
  CONSTRAINT `fk_author` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`)