ridgepole 0.7.2.beta → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/Appraisals +2 -4
- data/README.md +5 -5
- data/gemfiles/activerecord_5.0.gemfile +1 -0
- data/gemfiles/activerecord_5.2.gemfile +1 -4
- data/lib/ridgepole/diff.rb +2 -2
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/migrate/migrate_primary_key_spec.rb +35 -15
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40108f2b75644df8ce23f3d8a1aa0ee2107aa25c
|
4
|
+
data.tar.gz: fa253124674f5d34a96b0db3ba0e7594cbf42fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a12b6e017baf87cca9aae8b817c503efa4dfffbcffc7b2ffc5ab9e96278bbbebe0d7f06d8af034da55a2dd20fae70d35a8d4ba4b70f327ae95f9690f564aff3
|
7
|
+
data.tar.gz: ac5e4ef666a799b883f87238a4b35cd48d47b8e04d67152205c3ce19392f425d98126de95274ee660cb474097421f85fcfe29f0df05c7b5c40f0e15448f1ba21
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
appraise 'activerecord-5.0' do
|
2
2
|
gem 'activerecord', '~> 5.0.1'
|
3
|
+
gem "pg", "< 1.0.0"
|
3
4
|
end
|
4
5
|
|
5
6
|
appraise 'activerecord-5.1' do
|
@@ -8,8 +9,5 @@ end
|
|
8
9
|
|
9
10
|
appraise 'activerecord-5.2' do
|
10
11
|
gem 'mysql2', '~> 0.4.4'
|
11
|
-
|
12
|
-
git 'https://github.com/rails/rails.git' do
|
13
|
-
gem 'activerecord', '>= 5.2.0.beta2', '< 6'
|
14
|
-
end
|
12
|
+
gem 'activerecord', '~> 5.2.0'
|
15
13
|
end
|
data/README.md
CHANGED
@@ -5,10 +5,6 @@ Ridgepole is a tool to manage DB schema.
|
|
5
5
|
It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.html#types-of-schema-dumps), and updates DB schema according to DSL.
|
6
6
|
(like Chef/Puppet)
|
7
7
|
|
8
|
-
[![Prev Version](https://img.shields.io/badge/prev_version-0.6.6-brightgreen.svg)](https://rubygems.org/gems/ridgepole/versions/0.7.0.rc1)
|
9
|
-
[![Build Status](https://travis-ci.org/winebarrel/ridgepole.svg?branch=0.6)](https://travis-ci.org/winebarrel/ridgepole)
|
10
|
-
[![Coverage Status](https://coveralls.io/repos/github/winebarrel/ridgepole/badge.svg?branch=0.6)](https://coveralls.io/github/winebarrel/ridgepole?branch=0.6)
|
11
|
-
|
12
8
|
[![Gem Version](https://badge.fury.io/rb/ridgepole.svg)](http://badge.fury.io/rb/ridgepole)
|
13
9
|
[![Build Status](https://travis-ci.org/winebarrel/ridgepole.svg?branch=0.7)](https://travis-ci.org/winebarrel/ridgepole)
|
14
10
|
[![Coverage Status](https://coveralls.io/repos/github/winebarrel/ridgepole/badge.svg?branch=0.7)](https://coveralls.io/github/winebarrel/ridgepole?branch=0.7)
|
@@ -277,7 +273,11 @@ add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
|
277
273
|
|
278
274
|
execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
|
279
275
|
# Execute SQL only if there is no foreign key
|
280
|
-
c.raw_connection.query(
|
276
|
+
c.raw_connection.query(<<-SQL).each.length.zero?
|
277
|
+
SELECT 1 FROM information_schema.key_column_usage
|
278
|
+
WHERE TABLE_SCHEMA = 'bookshelf'
|
279
|
+
AND CONSTRAINT_NAME = 'fk_author' LIMIT 1
|
280
|
+
SQL
|
281
281
|
end
|
282
282
|
```
|
283
283
|
|
data/lib/ridgepole/diff.rb
CHANGED
@@ -139,9 +139,9 @@ class Ridgepole::Diff
|
|
139
139
|
to: #{to.slice(*PRIMARY_KEY_OPTIONS)}
|
140
140
|
EOS
|
141
141
|
end
|
142
|
-
from = from.except(*PRIMARY_KEY_OPTIONS)
|
143
|
-
to = to.except(*PRIMARY_KEY_OPTIONS)
|
144
142
|
end
|
143
|
+
from = from.except(*PRIMARY_KEY_OPTIONS)
|
144
|
+
to = to.except(*PRIMARY_KEY_OPTIONS)
|
145
145
|
|
146
146
|
unless from == to
|
147
147
|
@logger.warn(<<-EOS)
|
data/lib/ridgepole/version.rb
CHANGED
@@ -11,28 +11,48 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
11
11
|
|
12
12
|
context 'when allow_pk_change option is false' do
|
13
13
|
let(:allow_pk_change) { false }
|
14
|
-
let(:expected_dsl) {
|
15
|
-
erbh(<<-EOS)
|
16
|
-
create_table "employees", id: :bigint, unsigned: true, force: :cascade do |t|
|
17
|
-
end
|
18
|
-
EOS
|
19
|
-
}
|
20
14
|
|
21
|
-
|
22
|
-
|
15
|
+
context 'with difference' do
|
16
|
+
let(:expected_dsl) {
|
17
|
+
erbh(<<-EOS)
|
18
|
+
create_table "employees", id: :bigint, unsigned: true, force: :cascade do |t|
|
19
|
+
end
|
20
|
+
EOS
|
21
|
+
}
|
22
|
+
|
23
|
+
it {
|
24
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-EOS)
|
23
25
|
[WARNING] Primary key definition of `employees` differ but `allow_pk_change` option is false
|
24
26
|
from: {:id=>:integer, :unsigned=>true}
|
25
27
|
to: {:id=>:bigint, :unsigned=>true}
|
26
|
-
|
28
|
+
EOS
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
delta = subject.diff(expected_dsl)
|
31
|
+
expect(delta.differ?).to be_falsey
|
32
|
+
delta.migrate
|
33
|
+
expect(subject.dump).to match_ruby actual_dsl
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with no difference' do
|
38
|
+
let(:actual_dsl) {
|
39
|
+
erbh(<<-EOS)
|
40
|
+
create_table "employees", unsigned: true, force: :cascade do |t|
|
41
|
+
end
|
42
|
+
EOS
|
43
|
+
}
|
44
|
+
let(:expected_dsl) { actual_dsl }
|
45
|
+
|
46
|
+
it {
|
47
|
+
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
48
|
+
|
49
|
+
delta = subject.diff(expected_dsl)
|
50
|
+
expect(delta.differ?).to be_falsey
|
51
|
+
}
|
52
|
+
end
|
33
53
|
end
|
34
54
|
|
35
|
-
context 'when allow_pk_change option is
|
55
|
+
context 'when allow_pk_change option is true' do
|
36
56
|
let(:allow_pk_change) { true }
|
37
57
|
let(:expected_dsl) {
|
38
58
|
erbh(<<-EOS)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridgepole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.2
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -402,9 +402,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
402
402
|
version: 2.2.7
|
403
403
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
404
404
|
requirements:
|
405
|
-
- - "
|
405
|
+
- - ">="
|
406
406
|
- !ruby/object:Gem::Version
|
407
|
-
version:
|
407
|
+
version: '0'
|
408
408
|
requirements: []
|
409
409
|
rubyforge_project:
|
410
410
|
rubygems_version: 2.6.13
|