ridgepole 0.7.0.alpha2 → 0.7.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +1 -0
- data/docker-compose.yml +6 -0
- data/lib/ridgepole/cli/config.rb +1 -0
- data/lib/ridgepole/dsl_parser/table_definition.rb +6 -0
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql57/json/add_json_column_spec.rb +33 -0
- data/spec/mysql57/json/change_json_column_spec.rb +100 -0
- data/spec/mysql57/json/drop_json_column_spec.rb +33 -0
- data/spec/mysql57/virtual/add_virtual_column_spec.rb +35 -0
- data/spec/mysql57/virtual/change_virtual_column_spec.rb +38 -0
- data/spec/mysql57/virtual/drop_virtual_column_spec.rb +35 -0
- data/spec/spec_condition.rb +4 -0
- data/spec/spec_const.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +13 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cbdcb1cafcede044e48cfd8b7a9c2799c96c98a
|
4
|
+
data.tar.gz: 6c9a147a2162f3c51110d9b1ee6051229638760c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f9c72ae55df7d7dce3dd7a68fd4d5b37bdd5a43df49ed5c8038ad272242cbfdf305e2f5af415f6606057a94505f61b00f7dd9e6a23bfa43b6d9d980ac27dbf
|
7
|
+
data.tar.gz: 6356712998757d48fc5c54e3feef06e4c3580eed2d5cb81b265af9267fb3ebf3def563e81d38dc3761c5b1dcfe3e251399fcb22787df3b84c242023d03108b92
|
data/.travis.yml
CHANGED
@@ -16,8 +16,10 @@ before_script:
|
|
16
16
|
- sudo service postgresql stop
|
17
17
|
- docker-compose up -d
|
18
18
|
- function mysql_ping { mysqladmin -u root -h 127.0.0.1 -ppassword ping > /dev/null 2> /dev/null; }
|
19
|
+
- function mysql57_ping { mysqladmin -u root -h 127.0.0.1 -P 3307 -ppassword ping > /dev/null 2> /dev/null; }
|
19
20
|
- function pg_ping { PGPASSWORD=password pg_isready -U postgres -h 127.0.0.1 > /dev/null 2> /dev/null; }
|
20
21
|
- for i in {1..60}; do mysql_ping && break; sleep 1; done
|
22
|
+
- for i in {1..60}; do mysql57_ping && break; sleep 1; done
|
21
23
|
- for i in {1..60}; do pg_ping && break; sleep 1; done
|
22
24
|
script:
|
23
25
|
- bundle exec rake
|
@@ -26,7 +28,8 @@ gemfile:
|
|
26
28
|
- gemfiles/activerecord_5.1.gemfile
|
27
29
|
env:
|
28
30
|
matrix:
|
29
|
-
-
|
31
|
+
- MYSQL56=1
|
32
|
+
- MYSQL57=1
|
30
33
|
- POSTGRESQL=1
|
31
34
|
services:
|
32
35
|
- docker
|
data/README.md
CHANGED
data/docker-compose.yml
CHANGED
data/lib/ridgepole/cli/config.rb
CHANGED
@@ -57,6 +57,12 @@ class Ridgepole::DSLParser
|
|
57
57
|
:bit,
|
58
58
|
:bit_varying,
|
59
59
|
:money,
|
60
|
+
|
61
|
+
# https://github.com/rails/rails/blob/v5.1.1/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L184
|
62
|
+
:virtual,
|
63
|
+
|
64
|
+
# https://github.com/rails/rails/blob/v5.0.4/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L53
|
65
|
+
:json,
|
60
66
|
].uniq
|
61
67
|
|
62
68
|
TYPES.each do |column_type|
|
data/lib/ridgepole/version.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when add virtual column' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "books", force: :cascade do |t|
|
6
|
+
t.string "title", null: false
|
7
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
8
|
+
end
|
9
|
+
EOS
|
10
|
+
}
|
11
|
+
|
12
|
+
let(:expected_dsl) {
|
13
|
+
erbh(<<-EOS)
|
14
|
+
create_table "books", force: :cascade do |t|
|
15
|
+
t.string "title", null: false
|
16
|
+
t.json "attrs", null: false
|
17
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
18
|
+
end
|
19
|
+
EOS
|
20
|
+
}
|
21
|
+
|
22
|
+
before { subject.diff(actual_dsl).migrate }
|
23
|
+
subject { client }
|
24
|
+
|
25
|
+
it {
|
26
|
+
delta = subject.diff(expected_dsl)
|
27
|
+
expect(delta.differ?).to be_truthy
|
28
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
29
|
+
delta.migrate
|
30
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when change virtual column / not null -> null' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "books", force: :cascade do |t|
|
6
|
+
t.string "title", null: false
|
7
|
+
t.json "attrs", null: false
|
8
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
9
|
+
end
|
10
|
+
EOS
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:expected_dsl) {
|
14
|
+
erbh(<<-EOS)
|
15
|
+
create_table "books", force: :cascade do |t|
|
16
|
+
t.string "title", null: false
|
17
|
+
t.json "attrs"
|
18
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
19
|
+
end
|
20
|
+
EOS
|
21
|
+
}
|
22
|
+
|
23
|
+
before { subject.diff(actual_dsl).migrate }
|
24
|
+
subject { client }
|
25
|
+
|
26
|
+
it {
|
27
|
+
delta = subject.diff(expected_dsl)
|
28
|
+
expect(delta.differ?).to be_truthy
|
29
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
30
|
+
delta.migrate
|
31
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when change virtual column / json -> string' do
|
36
|
+
let(:actual_dsl) {
|
37
|
+
erbh(<<-EOS)
|
38
|
+
create_table "books", force: :cascade do |t|
|
39
|
+
t.string "title", null: false
|
40
|
+
t.json "attrs", null: false
|
41
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
42
|
+
end
|
43
|
+
EOS
|
44
|
+
}
|
45
|
+
|
46
|
+
let(:expected_dsl) {
|
47
|
+
erbh(<<-EOS)
|
48
|
+
create_table "books", force: :cascade do |t|
|
49
|
+
t.string "title", null: false
|
50
|
+
t.string "attrs"
|
51
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
52
|
+
end
|
53
|
+
EOS
|
54
|
+
}
|
55
|
+
|
56
|
+
before { subject.diff(actual_dsl).migrate }
|
57
|
+
subject { client }
|
58
|
+
|
59
|
+
it {
|
60
|
+
delta = subject.diff(expected_dsl)
|
61
|
+
expect(delta.differ?).to be_truthy
|
62
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
63
|
+
delta.migrate
|
64
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when change virtual column / string -> json' do
|
69
|
+
let(:actual_dsl) {
|
70
|
+
erbh(<<-EOS)
|
71
|
+
create_table "books", force: :cascade do |t|
|
72
|
+
t.string "title", null: false
|
73
|
+
t.string "attrs"
|
74
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
75
|
+
end
|
76
|
+
EOS
|
77
|
+
}
|
78
|
+
|
79
|
+
let(:expected_dsl) {
|
80
|
+
erbh(<<-EOS)
|
81
|
+
create_table "books", force: :cascade do |t|
|
82
|
+
t.string "title", null: false
|
83
|
+
t.json "attrs", null: false
|
84
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
85
|
+
end
|
86
|
+
EOS
|
87
|
+
}
|
88
|
+
|
89
|
+
before { subject.diff(actual_dsl).migrate }
|
90
|
+
subject { client }
|
91
|
+
|
92
|
+
it {
|
93
|
+
delta = subject.diff(expected_dsl)
|
94
|
+
expect(delta.differ?).to be_truthy
|
95
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
96
|
+
delta.migrate
|
97
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when add virtual column' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "books", force: :cascade do |t|
|
6
|
+
t.string "title", null: false
|
7
|
+
t.json "attrs", null: false
|
8
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
9
|
+
end
|
10
|
+
EOS
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:expected_dsl) {
|
14
|
+
erbh(<<-EOS)
|
15
|
+
create_table "books", force: :cascade do |t|
|
16
|
+
t.string "title", null: false
|
17
|
+
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
18
|
+
end
|
19
|
+
EOS
|
20
|
+
}
|
21
|
+
|
22
|
+
before { subject.diff(actual_dsl).migrate }
|
23
|
+
subject { client }
|
24
|
+
|
25
|
+
it {
|
26
|
+
delta = subject.diff(expected_dsl)
|
27
|
+
expect(delta.differ?).to be_truthy
|
28
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
29
|
+
delta.migrate
|
30
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
2
|
+
context 'when add virtual column' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-EOS
|
5
|
+
create_table "books", force: :cascade do |t|
|
6
|
+
t.string "title"
|
7
|
+
t.index ["title"], name: "index_books_on_title"
|
8
|
+
end
|
9
|
+
EOS
|
10
|
+
}
|
11
|
+
|
12
|
+
let(:expected_dsl) {
|
13
|
+
<<-EOS
|
14
|
+
create_table "books", force: :cascade do |t|
|
15
|
+
t.string "title"
|
16
|
+
t.virtual "upper_title", type: :string, as: "upper(`title`)"
|
17
|
+
t.virtual "title_length", type: :integer, as: "length(`title`)", stored: true
|
18
|
+
t.index ["title"], name: "index_books_on_title"
|
19
|
+
t.index ["title_length"], name: "index_books_on_title_length"
|
20
|
+
end
|
21
|
+
EOS
|
22
|
+
}
|
23
|
+
|
24
|
+
before { subject.diff(actual_dsl).migrate }
|
25
|
+
subject { client }
|
26
|
+
|
27
|
+
it {
|
28
|
+
delta = subject.diff(expected_dsl)
|
29
|
+
expect(delta.differ?).to be_truthy
|
30
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
31
|
+
delta.migrate
|
32
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
2
|
+
context 'when change virtual column' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-EOS
|
5
|
+
create_table "books", force: :cascade do |t|
|
6
|
+
t.string "title"
|
7
|
+
t.virtual "upper_title", type: :string, null: false, as: "upper(`title`)"
|
8
|
+
t.virtual "title_length", type: :integer, null: false, as: "length(`title`)", stored: true
|
9
|
+
t.index ["title"], name: "index_books_on_title"
|
10
|
+
t.index ["title_length"], name: "index_books_on_title_length"
|
11
|
+
end
|
12
|
+
EOS
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:expected_dsl) {
|
16
|
+
<<-EOS
|
17
|
+
create_table "books", force: :cascade do |t|
|
18
|
+
t.string "title"
|
19
|
+
t.virtual "upper_title", type: :string, null: false, as: "length(`title`)"
|
20
|
+
t.virtual "title_length", type: :integer, null: false, as: "upper(`title`)", stored: true
|
21
|
+
t.index ["title"], name: "index_books_on_title"
|
22
|
+
t.index ["title_length"], name: "index_books_on_title_length"
|
23
|
+
end
|
24
|
+
EOS
|
25
|
+
}
|
26
|
+
|
27
|
+
before { subject.diff(actual_dsl).migrate }
|
28
|
+
subject { client }
|
29
|
+
|
30
|
+
it {
|
31
|
+
delta = subject.diff(expected_dsl)
|
32
|
+
expect(delta.differ?).to be_truthy
|
33
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
34
|
+
delta.migrate
|
35
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
2
|
+
context 'when drop virtual column' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-EOS
|
5
|
+
create_table "books", force: :cascade do |t|
|
6
|
+
t.string "title"
|
7
|
+
t.virtual "upper_title", type: :string, as: "upper(`title`)"
|
8
|
+
t.virtual "title_length", type: :integer, as: "length(`title`)", stored: true
|
9
|
+
t.index ["title"], name: "index_books_on_title"
|
10
|
+
t.index ["title_length"], name: "index_books_on_title_length"
|
11
|
+
end
|
12
|
+
EOS
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:expected_dsl) {
|
16
|
+
<<-EOS
|
17
|
+
create_table "books", force: :cascade do |t|
|
18
|
+
t.string "title"
|
19
|
+
t.index ["title"], name: "index_books_on_title"
|
20
|
+
end
|
21
|
+
EOS
|
22
|
+
}
|
23
|
+
|
24
|
+
before { subject.diff(actual_dsl).migrate }
|
25
|
+
subject { client }
|
26
|
+
|
27
|
+
it {
|
28
|
+
delta = subject.diff(expected_dsl)
|
29
|
+
expect(delta.differ?).to be_truthy
|
30
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
31
|
+
delta.migrate
|
32
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_condition.rb
CHANGED
data/spec/spec_const.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridgepole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
4
|
+
version: 0.7.0.alpha3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
@@ -319,6 +319,12 @@ files:
|
|
319
319
|
- spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
|
320
320
|
- spec/mysql/~default_name_fk/migrate_create_fk_spec.rb
|
321
321
|
- spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb
|
322
|
+
- spec/mysql57/json/add_json_column_spec.rb
|
323
|
+
- spec/mysql57/json/change_json_column_spec.rb
|
324
|
+
- spec/mysql57/json/drop_json_column_spec.rb
|
325
|
+
- spec/mysql57/virtual/add_virtual_column_spec.rb
|
326
|
+
- spec/mysql57/virtual/change_virtual_column_spec.rb
|
327
|
+
- spec/mysql57/virtual/drop_virtual_column_spec.rb
|
322
328
|
- spec/postgresql/diff/diff_spec.rb
|
323
329
|
- spec/postgresql/dump/dump_spec.rb
|
324
330
|
- spec/postgresql/fk/migrate_change_fk_spec.rb
|
@@ -453,6 +459,12 @@ test_files:
|
|
453
459
|
- spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
|
454
460
|
- spec/mysql/~default_name_fk/migrate_create_fk_spec.rb
|
455
461
|
- spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb
|
462
|
+
- spec/mysql57/json/add_json_column_spec.rb
|
463
|
+
- spec/mysql57/json/change_json_column_spec.rb
|
464
|
+
- spec/mysql57/json/drop_json_column_spec.rb
|
465
|
+
- spec/mysql57/virtual/add_virtual_column_spec.rb
|
466
|
+
- spec/mysql57/virtual/change_virtual_column_spec.rb
|
467
|
+
- spec/mysql57/virtual/drop_virtual_column_spec.rb
|
456
468
|
- spec/postgresql/diff/diff_spec.rb
|
457
469
|
- spec/postgresql/dump/dump_spec.rb
|
458
470
|
- spec/postgresql/fk/migrate_change_fk_spec.rb
|