ridgepole 0.6.5 → 0.6.6.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +8 -2
- data/gemfiles/activerecord_5.0.gemfile +1 -1
- data/lib/ridgepole/cli/config.rb +25 -8
- data/lib/ridgepole/delta.rb +1 -1
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/cli/config_spec.rb +36 -1
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +7 -7
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43b2e1e6fe82bc1adaecdf2e03682a3bd1756e2d
|
4
|
+
data.tar.gz: 30ca92eea9cd6296e88293671a04d2511a4b3141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eef1346bb2cbd9884ebe22728fbb22456e393fb2fdc39b44d274f6bad03d5bffed364131216fa37500e2498ce87760786adb6e4e1141b288fe0e9327d5f9936
|
7
|
+
data.tar.gz: 073a3053fd3a2a2932d34cb03fc7122f13a283d50d7e73bca56c0bea03b7035f6d494d62d6724d1224163eadbfa53faa84c94357a428b1d6129517cea135b55e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
13
13
|
|
14
14
|
Please don't use the following nameless fk:
|
15
15
|
|
16
|
-
```ruby
|
16
|
+
```ruby
|
17
17
|
add_foreign_key :articles, :authors # without `name:`
|
18
18
|
```
|
19
19
|
|
@@ -69,6 +69,10 @@ add_foreign_key :articles, :authors # without `name:`
|
|
69
69
|
* Support DDL Comment (Rails5 only)
|
70
70
|
* Output schema diff when pass `--verbose`
|
71
71
|
* Support composite primary key (Rails5 only / [pull#97](https://github.com/winebarrel/ridgepole/pull/97))
|
72
|
+
* `>= 0.6.6`
|
73
|
+
* Use `t.column` for migration ([pull#114](https://github.com/winebarrel/ridgepole/pull/114))
|
74
|
+
* Support DATABASE_URL format ([pull#118](https://github.com/winebarrel/ridgepole/pull/118))
|
75
|
+
* Add Ruby2.4 CI ([pull#119](https://github.com/winebarrel/ridgepole/pull/119))
|
72
76
|
|
73
77
|
## Installation
|
74
78
|
|
@@ -138,7 +142,9 @@ encoding: utf8
|
|
138
142
|
database: blog
|
139
143
|
username: root
|
140
144
|
|
141
|
-
$ ridgepole -c config.yml --export -o Schemafile
|
145
|
+
$ ridgepole -c config.yml --export -o Schemafile
|
146
|
+
# or `ridgepole -c '{adapter: mysql2, database: blog}' ...`
|
147
|
+
# or `ridgepole -c 'mysql2://root:3306@127.0.0.1/blog' ...`
|
142
148
|
Export Schema to `Schemafile`
|
143
149
|
|
144
150
|
$ cat Schemafile
|
data/lib/ridgepole/cli/config.rb
CHANGED
@@ -4,15 +4,16 @@ require 'yaml'
|
|
4
4
|
class Ridgepole::Config
|
5
5
|
class << self
|
6
6
|
def load(config, env = 'development')
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
if File.exist?(config)
|
8
|
+
parsed_config = parse_config_file(config)
|
9
|
+
elsif (expanded = File.expand_path(config)) and File.exist?(expanded)
|
10
|
+
parsed_config = parse_config_file(expanded)
|
11
|
+
else
|
12
|
+
parsed_config = YAML.load(ERB.new(config).result)
|
13
|
+
end
|
12
14
|
|
13
15
|
unless parsed_config.kind_of?(Hash)
|
14
|
-
|
15
|
-
parse_config = parse_config_file(config)
|
16
|
+
parsed_config = parse_database_url(config)
|
16
17
|
end
|
17
18
|
|
18
19
|
if parsed_config.has_key?(env.to_s)
|
@@ -28,5 +29,21 @@ class Ridgepole::Config
|
|
28
29
|
yaml = ERB.new(File.read(path)).result
|
29
30
|
YAML.load(yaml)
|
30
31
|
end
|
31
|
-
|
32
|
+
|
33
|
+
def parse_database_url(config)
|
34
|
+
uri = URI.parse(config)
|
35
|
+
|
36
|
+
if [uri.scheme, uri.user, uri.password, uri.host, uri.path].any? {|i| i.nil? }
|
37
|
+
raise "Invalid config: #{config.inspect}"
|
38
|
+
end
|
39
|
+
|
40
|
+
{
|
41
|
+
'adapter' => uri.scheme,
|
42
|
+
'username' => uri.user,
|
43
|
+
'password' => uri.password,
|
44
|
+
'host' => uri.host,
|
45
|
+
'database' => uri.path.sub(%r|\A/|, ''),
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end # of class methods
|
32
49
|
end
|
data/lib/ridgepole/delta.rb
CHANGED
@@ -227,7 +227,7 @@ create_table(#{table_name.inspect}, #{inspect_options_include_default_proc(optio
|
|
227
227
|
normalize_limit(column_type, column_options)
|
228
228
|
|
229
229
|
buf.puts(<<-EOS)
|
230
|
-
t
|
230
|
+
t.column(#{column_name.inspect}, :#{column_type.to_s.inspect}, #{inspect_options_include_default_proc(column_options)})
|
231
231
|
EOS
|
232
232
|
end
|
233
233
|
|
data/lib/ridgepole/version.rb
CHANGED
@@ -71,6 +71,29 @@ describe Ridgepole::Config do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
context 'when passed yaml file' do
|
75
|
+
let(:config) {
|
76
|
+
<<-YAML.strip_heredoc
|
77
|
+
adapter: mysql2
|
78
|
+
encoding: utf8
|
79
|
+
database: blog
|
80
|
+
username: root
|
81
|
+
YAML
|
82
|
+
}
|
83
|
+
let(:env) { 'development' }
|
84
|
+
it {
|
85
|
+
Tempfile.create("database.yml") do |f|
|
86
|
+
f.puts config
|
87
|
+
f.flush
|
88
|
+
|
89
|
+
expect(subject['adapter']).to eq "mysql2"
|
90
|
+
expect(subject['encoding']).to eq "utf8"
|
91
|
+
expect(subject['database']).to eq "blog"
|
92
|
+
expect(subject['username']).to eq "root"
|
93
|
+
end
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
74
97
|
context 'when passed unexisting yaml' do
|
75
98
|
let(:config) {
|
76
99
|
'database.yml'
|
@@ -81,7 +104,19 @@ describe Ridgepole::Config do
|
|
81
104
|
it {
|
82
105
|
expect {
|
83
106
|
subject
|
84
|
-
}.to raise_error
|
107
|
+
}.to raise_error 'Invalid config: "database.yml"'
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when passed DATABASE_URL' do
|
112
|
+
let(:config) { 'mysql2://root:1234@127.0.0.1/blog' }
|
113
|
+
let(:env) { 'development' }
|
114
|
+
|
115
|
+
it {
|
116
|
+
expect(subject['adapter']).to eq "mysql2"
|
117
|
+
expect(subject['database']).to eq "blog"
|
118
|
+
expect(subject['username']).to eq "root"
|
119
|
+
expect(subject['password']).to eq "1234"
|
85
120
|
}
|
86
121
|
end
|
87
122
|
end
|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
19
19
|
|
20
20
|
expect(delta.script).to match_fuzzy <<-EOS
|
21
21
|
create_table("employee_clubs", {:options=>"ENGINE=MyISAM CHARSET=utf8"}) do |t|
|
22
|
-
t.
|
23
|
-
t.
|
22
|
+
t.column("emp_no", :"integer", {:null=>false, :unsigned=>true, :limit=>4})
|
23
|
+
t.column("club_id", :"integer", {:null=>false, :unsigned=>true, :limit=>4})
|
24
24
|
end
|
25
25
|
add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
|
26
26
|
EOS
|
@@ -135,22 +135,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
135
135
|
expect(delta.differ?).to be_truthy
|
136
136
|
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
137
137
|
create_table("clubs", <%= unsigned(true) %>) do |t|
|
138
|
-
t.
|
138
|
+
t.column("name", :"string", <%= limit(255) >> {default: "", null: false, limit: 255} %>)
|
139
139
|
end
|
140
140
|
add_index("clubs", ["name"], {:name=>"idx_name", :unique=>true, :using=>:btree})
|
141
141
|
|
142
142
|
create_table("employee_clubs", <%= unsigned(true) %>) do |t|
|
143
|
-
t.
|
144
|
-
t.
|
143
|
+
t.column("emp_no", :"integer", <%= limit(4) >> {null: false, limit: 4} + unsigned(true) %>)
|
144
|
+
t.column("club_id", :"integer", <%= limit(4) >> {null: false, limit: 4} + unsigned(true) %>)
|
145
145
|
end
|
146
146
|
add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
|
147
147
|
|
148
148
|
create_table("employees", <%= {primary_key: "emp_no"} + unsigned(true) %>) do |t|
|
149
|
-
t.
|
150
|
-
t.
|
151
|
-
t.
|
152
|
-
t.
|
153
|
-
t.
|
149
|
+
t.column("birth_date", :"date", {:null=>false})
|
150
|
+
t.column("first_name", :"string", {:limit=>14, :null=>false})
|
151
|
+
t.column("last_name", :"string", {:limit=>16, :null=>false})
|
152
|
+
t.column("gender", :"string", {:limit=>1, :null=>false})
|
153
|
+
t.column("hire_date", :"date", {:null=>false})
|
154
154
|
end
|
155
155
|
EOS
|
156
156
|
}
|
@@ -134,21 +134,21 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
expect(delta.differ?).to be_truthy
|
135
135
|
expect(delta.script).to match_fuzzy <<-EOS
|
136
136
|
create_table("clubs", {}) do |t|
|
137
|
-
t.
|
137
|
+
t.column("name", :"string", {:limit=>255, :default=>"", :null=>false})
|
138
138
|
end
|
139
139
|
add_index("clubs", ["name"], {:name=>"idx_name", :unique=>true, :using=>:btree})
|
140
140
|
|
141
141
|
create_table("employee_clubs", {}) do |t|
|
142
|
-
t.
|
143
|
-
t.
|
142
|
+
t.column("emp_no", :"integer", {:null=>false})
|
143
|
+
t.column("club_id", :"integer", {:null=>false})
|
144
144
|
end
|
145
145
|
add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_employee_clubs_emp_no_club_id", :using=>:btree})
|
146
146
|
|
147
147
|
create_table("employees", {:primary_key=>"emp_no"}) do |t|
|
148
|
-
t.
|
149
|
-
t.
|
150
|
-
t.
|
151
|
-
t.
|
148
|
+
t.column("birth_date", :"date", {:null=>false})
|
149
|
+
t.column("first_name", :"string", {:limit=>14, :null=>false})
|
150
|
+
t.column("last_name", :"string", {:limit=>16, :null=>false})
|
151
|
+
t.column("hire_date", :"date", {:null=>false})
|
152
152
|
end
|
153
153
|
EOS
|
154
154
|
}
|
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.6.
|
4
|
+
version: 0.6.6.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -360,12 +360,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
360
360
|
version: '0'
|
361
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
362
362
|
requirements:
|
363
|
-
- - "
|
363
|
+
- - ">"
|
364
364
|
- !ruby/object:Gem::Version
|
365
|
-
version:
|
365
|
+
version: 1.3.1
|
366
366
|
requirements: []
|
367
367
|
rubyforge_project:
|
368
|
-
rubygems_version: 2.5.
|
368
|
+
rubygems_version: 2.5.2
|
369
369
|
signing_key:
|
370
370
|
specification_version: 4
|
371
371
|
summary: Ridgepole is a tool to manage DB schema.
|