ridgepole 0.6.5.beta → 0.6.5.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -2
  3. data/Appraisals +1 -1
  4. data/README.md +3 -1
  5. data/gemfiles/activerecord_5.0.gemfile +1 -1
  6. data/lib/ridgepole/client.rb +5 -1
  7. data/lib/ridgepole/delta.rb +21 -5
  8. data/lib/ridgepole/diff.rb +13 -2
  9. data/lib/ridgepole/dsl_parser.rb +38 -3
  10. data/lib/ridgepole/dumper.rb +2 -2
  11. data/lib/ridgepole/ext/abstract_mysql_adapter/disable_table_options.rb +21 -0
  12. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +28 -0
  13. data/lib/ridgepole/version.rb +1 -1
  14. data/ridgepole.gemspec +3 -3
  15. data/spec/erb_helper.rb +43 -0
  16. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
  17. data/spec/mysql/collation/collation_spec.rb +39 -37
  18. data/spec/mysql/default_lambda/default_lambda_spec.rb +162 -0
  19. data/spec/mysql/diff/diff2_spec.rb +10 -10
  20. data/spec/mysql/diff/diff_spec.rb +6 -6
  21. data/spec/mysql/dump/dump_class_method_spec.rb +56 -39
  22. data/spec/mysql/dump/dump_some_tables_spec.rb +21 -13
  23. data/spec/mysql/dump/dump_spec.rb +49 -36
  24. data/spec/mysql/dump/dump_without_table_options_spec.rb +27 -9
  25. data/spec/mysql/fk/migrate_change_fk_spec.rb +17 -11
  26. data/spec/mysql/fk/migrate_create_fk_spec.rb +20 -18
  27. data/spec/mysql/fk/migrate_drop_fk_spec.rb +30 -16
  28. data/spec/mysql/migrate/migrate_add_column2_spec.rb +10 -8
  29. data/spec/mysql/migrate/migrate_add_column_spec.rb +49 -61
  30. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +46 -58
  31. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +46 -58
  32. data/spec/mysql/migrate/migrate_change_column2_spec.rb +12 -24
  33. data/spec/mysql/migrate/migrate_change_column3_spec.rb +18 -30
  34. data/spec/mysql/migrate/migrate_change_column5_spec.rb +8 -20
  35. data/spec/mysql/migrate/migrate_change_column6_spec.rb +8 -8
  36. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +20 -20
  37. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +2 -2
  38. data/spec/mysql/migrate/migrate_change_column_spec.rb +54 -68
  39. data/spec/mysql/migrate/migrate_change_index2_spec.rb +14 -14
  40. data/spec/mysql/migrate/migrate_change_index3_spec.rb +28 -28
  41. data/spec/mysql/migrate/migrate_change_index4_spec.rb +26 -38
  42. data/spec/mysql/migrate/migrate_change_index5_spec.rb +20 -32
  43. data/spec/mysql/migrate/migrate_change_index6_spec.rb +63 -75
  44. data/spec/mysql/migrate/migrate_change_index_spec.rb +62 -74
  45. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +8 -20
  46. data/spec/mysql/migrate/migrate_create_index2_spec.rb +98 -53
  47. data/spec/mysql/migrate/migrate_create_index_spec.rb +84 -39
  48. data/spec/mysql/migrate/migrate_create_table_spec.rb +69 -39
  49. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +69 -39
  50. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +47 -59
  51. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +43 -55
  52. data/spec/mysql/migrate/migrate_drop_column_spec.rb +48 -60
  53. data/spec/mysql/migrate/migrate_drop_index_spec.rb +84 -39
  54. data/spec/mysql/migrate/migrate_drop_table_spec.rb +76 -46
  55. data/spec/mysql/migrate/migrate_empty_spec.rb +24 -36
  56. data/spec/mysql/migrate/migrate_execute_spec.rb +30 -32
  57. data/spec/mysql/migrate/migrate_log_file_spec.rb +69 -39
  58. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +48 -48
  59. data/spec/mysql/migrate/migrate_noop_spec.rb +23 -13
  60. data/spec/mysql/migrate/migrate_rename_column_spec.rb +48 -60
  61. data/spec/mysql/migrate/migrate_rename_table_spec.rb +56 -68
  62. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +8 -20
  63. data/spec/mysql/migrate/migrate_same_spec.rb +49 -31
  64. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +48 -60
  65. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +48 -60
  66. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +34 -34
  67. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +84 -39
  68. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +84 -39
  69. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +84 -0
  70. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +14 -8
  71. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +15 -27
  72. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +10 -10
  73. data/spec/postgresql/dump/dump_spec.rb +40 -16
  74. data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
  75. data/spec/postgresql/fk/migrate_create_fk_spec.rb +11 -11
  76. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
  77. data/spec/postgresql/migrate/migrate_add_column_spec.rb +20 -20
  78. data/spec/postgresql/migrate/migrate_change_column_spec.rb +20 -20
  79. data/spec/postgresql/migrate/migrate_change_index_spec.rb +20 -20
  80. data/spec/postgresql/migrate/migrate_create_table_spec.rb +52 -12
  81. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +20 -20
  82. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +18 -18
  83. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +69 -13
  84. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +55 -13
  85. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +3 -1
  86. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +20 -20
  87. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +24 -24
  88. data/spec/postgresql/migrate/migrate_same_spec.rb +40 -16
  89. data/spec/postgresql/ridgepole_test_tables.sql +3 -0
  90. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
  91. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +11 -11
  92. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
  93. data/spec/spec_condition.rb +14 -2
  94. data/spec/spec_helper.rb +12 -11
  95. data/spec/string_ext.rb +2 -0
  96. metadata +16 -9
  97. data/lib/ridgepole/ext/abstract_mysql_adapter.rb +0 -26
@@ -0,0 +1,84 @@
1
+ describe 'Ridgepole::Client (with new text/blob types)', condition: [:activerecord_5] do
2
+ context 'when use new types' do
3
+ subject { client }
4
+
5
+ it do
6
+ delta = subject.diff(<<-EOS)
7
+ create_table :foos do |t|
8
+ t.blob :blob
9
+ t.tinyblob :tiny_blob
10
+ t.mediumblob :medium_blob
11
+ t.longblob :long_blob
12
+ t.tinytext :tiny_text
13
+ t.mediumtext :medium_text
14
+ t.longtext :long_text
15
+ t.unsigned_decimal :unsigned_decimal
16
+ t.unsigned_float :unsigned_float
17
+ t.unsigned_bigint :unsigned_bigint
18
+ t.unsigned_integer :unsigned_integer
19
+ end
20
+ EOS
21
+
22
+ expect(delta.differ?).to be_truthy
23
+ delta.migrate
24
+
25
+ expect(subject.dump).to match_fuzzy <<-EOS
26
+ create_table "foos", force: :cascade do |t|
27
+ t.binary "blob", limit: 65535
28
+ t.blob "tiny_blob", limit: 255
29
+ t.binary "medium_blob", limit: 16777215
30
+ t.binary "long_blob", limit: 4294967295
31
+ t.text "tiny_text", limit: 255
32
+ t.text "medium_text", limit: 16777215
33
+ t.text "long_text", limit: 4294967295
34
+ t.decimal "unsigned_decimal", precision: 10, unsigned: true
35
+ t.float "unsigned_float", limit: 24, unsigned: true
36
+ t.bigint "unsigned_bigint", unsigned: true
37
+ t.integer "unsigned_integer", unsigned: true
38
+ end
39
+ EOS
40
+ end
41
+ end
42
+
43
+ context 'when compare new types' do
44
+ subject { client }
45
+
46
+ before do
47
+ subject.diff(<<-EOS).migrate
48
+ create_table :foos do |t|
49
+ t.blob :blob
50
+ t.tinyblob :tiny_blob
51
+ t.mediumblob :medium_blob
52
+ t.longblob :long_blob
53
+ t.tinytext :tiny_text
54
+ t.mediumtext :medium_text
55
+ t.longtext :long_text
56
+ t.unsigned_decimal :unsigned_decimal
57
+ t.unsigned_float :unsigned_float
58
+ t.unsigned_bigint :unsigned_bigint
59
+ t.unsigned_integer :unsigned_integer
60
+ end
61
+ EOS
62
+ end
63
+
64
+ it do
65
+ delta = subject.diff(<<-EOS)
66
+ create_table :foos do |t|
67
+ t.blob :blob
68
+ t.tinyblob :tiny_blob
69
+ t.mediumblob :medium_blob
70
+ t.longblob :long_blob
71
+ t.tinytext :tiny_text
72
+ t.mediumtext :medium_text
73
+ t.longtext :long_text
74
+ t.unsigned_decimal :unsigned_decimal
75
+ t.unsigned_float :unsigned_float
76
+ t.unsigned_bigint :unsigned_bigint
77
+ t.unsigned_integer :unsigned_integer
78
+ end
79
+ EOS
80
+
81
+ expect(delta.differ?).to be_falsey
82
+ end
83
+ end
84
+ end
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change fk' do
3
3
  let(:actual_dsl) {
4
- <<-EOS
4
+ erbh(<<-EOS)
5
5
  create_table "parent", force: :cascade do |t|
6
6
  end
7
7
 
@@ -9,19 +9,19 @@ create_table "child", force: :cascade do |t|
9
9
  t.integer "parent_id"
10
10
  end
11
11
 
12
- add_index "child", ["parent_id"], name: "par_id", using: :btree
12
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
13
13
 
14
14
  add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
15
15
  EOS
16
16
  }
17
17
 
18
18
  let(:sorted_actual_dsl) {
19
- <<-EOS
19
+ erbh(<<-EOS)
20
20
  create_table "child", force: :cascade do |t|
21
- t.integer "parent_id", limit: 4
21
+ t.integer "parent_id", <%= i limit(4) %>
22
22
  end
23
23
 
24
- add_index "child", ["parent_id"], name: "par_id", using: :btree
24
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
25
25
 
26
26
  create_table "parent", force: :cascade do |t|
27
27
  end
@@ -31,12 +31,12 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :casc
31
31
  }
32
32
 
33
33
  let(:expected_dsl) {
34
- <<-EOS
34
+ erbh(<<-EOS)
35
35
  create_table "child", force: :cascade do |t|
36
- t.integer "parent_id", limit: 4
36
+ t.integer "parent_id", <%= i limit(4) %>
37
37
  end
38
38
 
39
- add_index "child", ["parent_id"], name: "par_id", using: :btree
39
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
40
40
 
41
41
  create_table "parent", force: :cascade do |t|
42
42
  end
@@ -54,6 +54,12 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
54
54
  expect(delta.differ?).to be_truthy
55
55
  expect(subject.dump).to match_fuzzy sorted_actual_dsl
56
56
  delta.migrate
57
+
58
+ # XXX:
59
+ if condition(:activerecord_5)
60
+ ActiveRecord::Base.connection.send(:create_table_info_cache).clear
61
+ end
62
+
57
63
  expect(subject.dump).to match_fuzzy expected_dsl
58
64
  }
59
65
  end
@@ -1,26 +1,14 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
- let(:template_variables) {
3
- opts = {
4
- unsigned: {}
5
- }
6
-
7
- if condition(:mysql_awesome_enabled)
8
- opts[:unsigned] = {unsigned: true}
9
- end
10
-
11
- opts
12
- }
13
-
14
2
  context 'when create fk' do
15
3
  let(:actual_dsl) {
16
- erbh(<<-EOS, template_variables)
17
- create_table "child", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
18
- t.integer "parent_id", <%= {limit: 4}.push(@unsigned).i %>
4
+ erbh(<<-EOS)
5
+ create_table "child", <%= i unsigned(true) + {force: :cascade} %> do |t|
6
+ t.integer "parent_id", <%= i limit(4) + unsigned(true) %>
19
7
  end
20
8
 
21
- add_index "child", ["parent_id"], name: "par_id", using: :btree
9
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
22
10
 
23
- create_table "parent", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
11
+ create_table "parent", <%= i unsigned(true) + {force: :cascade} %> do |t|
24
12
  end
25
13
  EOS
26
14
  }
@@ -65,7 +53,7 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
65
53
 
66
54
  context 'when create fk when create table' do
67
55
  let(:dsl) {
68
- <<-EOS
56
+ erbh(<<-EOS)
69
57
  # Define parent before child
70
58
  create_table "parent", force: :cascade do |t|
71
59
  end
@@ -74,20 +62,20 @@ create_table "child", force: :cascade do |t|
74
62
  t.integer "parent_id"
75
63
  end
76
64
 
77
- add_index "child", ["parent_id"], name: "par_id", using: :btree
65
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
78
66
 
79
67
  add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
80
68
  EOS
81
69
  }
82
70
 
83
71
  let(:sorted_dsl) {
84
- <<-EOS
72
+ erbh(<<-EOS)
85
73
 
86
74
  create_table "child", force: :cascade do |t|
87
- t.integer "parent_id", limit: 4
75
+ t.integer "parent_id", <%= i limit(4) %>
88
76
  end
89
77
 
90
- add_index "child", ["parent_id"], name: "par_id", using: :btree
78
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
91
79
 
92
80
  create_table "parent", force: :cascade do |t|
93
81
  end
@@ -109,7 +97,7 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
109
97
 
110
98
  context 'already defined' do
111
99
  let(:dsl) {
112
- <<-EOS
100
+ erbh(<<-EOS)
113
101
  # Define parent before child
114
102
  create_table "parent", force: :cascade do |t|
115
103
  end
@@ -118,7 +106,7 @@ create_table "child", force: :cascade do |t|
118
106
  t.integer "parent_id", unsigned: true
119
107
  end
120
108
 
121
- add_index "child", ["parent_id"], name: "par_id", using: :btree
109
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
122
110
 
123
111
  add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
124
112
 
@@ -137,7 +125,7 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
137
125
 
138
126
  context 'no name' do
139
127
  let(:dsl) {
140
- <<-EOS
128
+ erbh(<<-EOS)
141
129
  # Define parent before child
142
130
  create_table "parent", force: :cascade do |t|
143
131
  end
@@ -146,7 +134,7 @@ create_table "child", force: :cascade do |t|
146
134
  t.integer "parent_id", unsigned: true
147
135
  end
148
136
 
149
- add_index "child", ["parent_id"], name: "par_id", using: :btree
137
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
150
138
 
151
139
  add_foreign_key "child", "parent"
152
140
  EOS
@@ -163,7 +151,7 @@ add_foreign_key "child", "parent"
163
151
 
164
152
  context 'orphan fk' do
165
153
  let(:dsl) {
166
- <<-EOS
154
+ erbh(<<-EOS)
167
155
  # Define parent before child
168
156
  create_table "parent", force: :cascade do |t|
169
157
  end
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when drop fk' do
3
3
  let(:actual_dsl) {
4
- <<-EOS
4
+ erbh(<<-EOS)
5
5
  create_table "parent", force: :cascade do |t|
6
6
  end
7
7
 
@@ -9,7 +9,7 @@ create_table "child", force: :cascade do |t|
9
9
  t.integer "parent_id"
10
10
  end
11
11
 
12
- add_index "child", ["parent_id"], name: "par_id", using: :btree
12
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
13
13
 
14
14
  add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
15
15
  EOS
@@ -23,12 +23,12 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
23
23
  }
24
24
 
25
25
  let(:expected_dsl) {
26
- <<-EOS
26
+ erbh(<<-EOS)
27
27
  create_table "child", force: :cascade do |t|
28
- t.integer "parent_id", limit: 4
28
+ t.integer "parent_id", <%= i limit(4) %>
29
29
  end
30
30
 
31
- add_index "child", ["parent_id"], name: "par_id", using: :btree
31
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
32
32
 
33
33
  create_table "parent", force: :cascade do |t|
34
34
  end
@@ -68,7 +68,7 @@ end
68
68
 
69
69
  context 'when drop fk when drop table' do
70
70
  let(:dsl) {
71
- <<-EOS
71
+ erbh(<<-EOS)
72
72
  create_table "parent", force: :cascade do |t|
73
73
  end
74
74
 
@@ -77,19 +77,19 @@ create_table "child", force: :cascade do |t|
77
77
  t.integer "parent_id"
78
78
  end
79
79
 
80
- add_index "child", ["parent_id"], name: "par_id", using: :btree
80
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
81
81
 
82
82
  add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
83
83
  EOS
84
84
  }
85
85
 
86
86
  let(:sorted_dsl) {
87
- <<-EOS
87
+ erbh(<<-EOS)
88
88
  create_table "child", force: :cascade do |t|
89
- t.integer "parent_id", limit: 4
89
+ t.integer "parent_id", <%= i limit(4) %>
90
90
  end
91
91
 
92
- add_index "child", ["parent_id"], name: "par_id", using: :btree
92
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
93
93
 
94
94
  create_table "parent", force: :cascade do |t|
95
95
  end
@@ -1,73 +1,97 @@
1
1
  describe 'Ridgepole::Client#dump' do
2
+ let(:template_variables) {
3
+ opts = {
4
+ departments_ext: {id: :string, limit: 4},
5
+ employees_ext: {id: :integer},
6
+ dept_manager_pk: {primary_key: ["emp_no", "dept_no"]},
7
+ dept_emp_pk: {primary_key: ["emp_no", "dept_no"]},
8
+ salaries_pk: {primary_key: ["emp_no", "from_date"]},
9
+ titles_pk: {primary_key: ["emp_no", "title", "from_date"]},
10
+ }
11
+
12
+ if condition(:activerecord_4)
13
+ opts.merge!(
14
+ departments_ext: {},
15
+ employees_ext: {},
16
+ dept_manager_pk: {id: false},
17
+ dept_emp_pk: {id: false},
18
+ salaries_pk: {id: false},
19
+ titles_pk: {id: false}
20
+ )
21
+ end
22
+
23
+ opts
24
+ }
25
+
2
26
  context 'when there is a tables' do
3
27
  before { restore_tables }
4
28
  subject { client }
5
29
 
6
30
  it {
7
- expect(subject.dump).to match_fuzzy <<-EOS
31
+ expect(subject.dump).to match_fuzzy erbh(<<-EOS, template_variables)
8
32
  create_table "clubs", force: :cascade do |t|
9
33
  t.string "name", limit: 255, default: "", null: false
10
34
  end
11
35
 
12
- add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
36
+ <%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
13
37
 
14
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
38
+ create_table "departments", primary_key: "dept_no", <%= i @departments_ext %>, force: :cascade do |t|
15
39
  t.string "dept_name", limit: 40, null: false
16
40
  end
17
41
 
18
- add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree
42
+ <%= add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree %>
19
43
 
20
- create_table "dept_emp", id: false, force: :cascade do |t|
44
+ create_table "dept_emp", <%= i @dept_emp_pk %>, force: :cascade do |t|
21
45
  t.integer "emp_no", null: false
22
46
  t.string "dept_no", limit: 4, null: false
23
47
  t.date "from_date", null: false
24
48
  t.date "to_date", null: false
25
49
  end
26
50
 
27
- add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree
28
- add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree
51
+ <%= add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree %>
52
+ <%= add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree %>
29
53
 
30
- create_table "dept_manager", id: false, force: :cascade do |t|
54
+ create_table "dept_manager", <%= i @dept_manager_pk %>, force: :cascade do |t|
31
55
  t.string "dept_no", limit: 4, null: false
32
56
  t.integer "emp_no", null: false
33
57
  t.date "from_date", null: false
34
58
  t.date "to_date", null: false
35
59
  end
36
60
 
37
- add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree
38
- add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree
61
+ <%= add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree %>
62
+ <%= add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree %>
39
63
 
40
64
  create_table "employee_clubs", force: :cascade do |t|
41
65
  t.integer "emp_no", null: false
42
66
  t.integer "club_id", null: false
43
67
  end
44
68
 
45
- add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", using: :btree
69
+ <%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", using: :btree %>
46
70
 
47
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
71
+ create_table "employees", primary_key: "emp_no", <%= i @employees_ext %>, force: :cascade do |t|
48
72
  t.date "birth_date", null: false
49
73
  t.string "first_name", limit: 14, null: false
50
74
  t.string "last_name", limit: 16, null: false
51
75
  t.date "hire_date", null: false
52
76
  end
53
77
 
54
- create_table "salaries", id: false, force: :cascade do |t|
78
+ create_table "salaries", <%= i @salaries_pk %>, force: :cascade do |t|
55
79
  t.integer "emp_no", null: false
56
80
  t.integer "salary", null: false
57
81
  t.date "from_date", null: false
58
82
  t.date "to_date", null: false
59
83
  end
60
84
 
61
- add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree
85
+ <%= add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree %>
62
86
 
63
- create_table "titles", id: false, force: :cascade do |t|
87
+ create_table "titles", <%= i @titles_pk %>, force: :cascade do |t|
64
88
  t.integer "emp_no", null: false
65
89
  t.string "title", limit: 50, null: false
66
90
  t.date "from_date", null: false
67
91
  t.date "to_date"
68
92
  end
69
93
 
70
- add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
94
+ <%= add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree %>
71
95
  EOS
72
96
  }
73
97
  end
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change fk' do
3
3
  let(:actual_dsl) {
4
- <<-EOS
4
+ erbh(<<-EOS)
5
5
  create_table "parent", force: :cascade do |t|
6
6
  end
7
7
 
@@ -9,19 +9,19 @@ create_table "child", force: :cascade do |t|
9
9
  t.integer "parent_id"
10
10
  end
11
11
 
12
- add_index "child", ["parent_id"], name: "par_id", using: :btree
12
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
13
13
 
14
14
  add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
15
15
  EOS
16
16
  }
17
17
 
18
18
  let(:sorted_actual_dsl) {
19
- <<-EOS
19
+ erbh(<<-EOS)
20
20
  create_table "child", force: :cascade do |t|
21
21
  t.integer "parent_id"
22
22
  end
23
23
 
24
- add_index "child", ["parent_id"], name: "par_id", using: :btree
24
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
25
25
 
26
26
  create_table "parent", force: :cascade do |t|
27
27
  end
@@ -31,12 +31,12 @@ add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
31
31
  }
32
32
 
33
33
  let(:expected_dsl) {
34
- <<-EOS
34
+ erbh(<<-EOS)
35
35
  create_table "child", force: :cascade do |t|
36
36
  t.integer "parent_id"
37
37
  end
38
38
 
39
- add_index "child", ["parent_id"], name: "par_id", using: :btree
39
+ <%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
40
40
 
41
41
  create_table "parent", force: :cascade do |t|
42
42
  end