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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 062b636d39f10f64c5fc0b450021c914121982bc
4
- data.tar.gz: 7948f752d4a6165ce5b95926ed910c47b32587af
3
+ metadata.gz: 5cbdcb1cafcede044e48cfd8b7a9c2799c96c98a
4
+ data.tar.gz: 6c9a147a2162f3c51110d9b1ee6051229638760c
5
5
  SHA512:
6
- metadata.gz: aeab93ec074378be562709f3984dee5716381c961aa04e845fe78646cc40ee47a1e57caaad5bed77fd11639c5d3d6ad4db4a7a5e1055e320906cb9d2168a9ea8
7
- data.tar.gz: 9fabbad5e5158b4916d1772352ca735a82363a41f11eaadae7776e789644c844dbd87d5b48d8b036cfb9ceb5a08c9bb612171ce1e5af833d4424e7b79a0746a7
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
- - POSTGRESQL=0
31
+ - MYSQL56=1
32
+ - MYSQL57=1
30
33
  - POSTGRESQL=1
31
34
  services:
32
35
  - docker
data/README.md CHANGED
@@ -79,6 +79,7 @@ add_foreign_key :articles, :authors # without `name:`
79
79
  * Remove `--enable-mysql-awesome` option
80
80
  * Add `--skip-drop-table` option
81
81
  * Support foreign key without name
82
+ * Support MySQL JSON Type and Generated Columns
82
83
 
83
84
  ## Installation
84
85
 
data/docker-compose.yml CHANGED
@@ -4,6 +4,12 @@ mysql:
4
4
  - "3306:3306"
5
5
  environment:
6
6
  MYSQL_ROOT_PASSWORD: password
7
+ mysql57:
8
+ image: "mysql:5.7"
9
+ ports:
10
+ - "3307:3306"
11
+ environment:
12
+ MYSQL_ROOT_PASSWORD: password
7
13
  postgres:
8
14
  image: "postgres:9.5"
9
15
  ports:
@@ -42,6 +42,7 @@ class Ridgepole::Config
42
42
  'username' => uri.user,
43
43
  'password' => uri.password,
44
44
  'host' => uri.host,
45
+ 'port' => uri.port,
45
46
  'database' => uri.path.sub(%r|\A/|, ''),
46
47
  }
47
48
  end
@@ -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|
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.7.0.alpha2'
2
+ VERSION = '0.7.0.alpha3'
3
3
  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.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
@@ -6,6 +6,10 @@ module SpecCondition
6
6
  ENV['POSTGRESQL'] == '1'
7
7
  end
8
8
 
9
+ def mysql57?
10
+ ENV['MYSQL57'] == '1'
11
+ end
12
+
9
13
  def mysql_awesome_enabled?
10
14
  ENV['ENABLE_MYSQL_AWESOME'] == '1'
11
15
  end
data/spec/spec_const.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  TEST_MYSQL_HOST = '127.0.0.1'
2
- TEST_MYSQL_PORT = 3306
2
+ TEST_MYSQL_PORT = ENV['MYSQL57'] == '1' ? 3307 : 3306
3
3
  TEST_MYSQL_USER = 'root'
4
4
  TEST_MYSQL_PASS = 'password'
5
5
 
data/spec/spec_helper.rb CHANGED
@@ -39,6 +39,8 @@ RSpec.configure do |config|
39
39
  end
40
40
 
41
41
  case example.metadata[:file_path]
42
+ when /mysql57/
43
+ skip unless condition(:mysql57)
42
44
  when /mysql/
43
45
  skip if condition(:postgresql)
44
46
  when /postgresql/
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.alpha2
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