ridgepole 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.travis.yml +4 -7
- data/README.md +3 -0
- data/bin/ridgepole +4 -2
- data/lib/ridgepole/cli/config.rb +5 -3
- data/lib/ridgepole/external_sql_executer.rb +1 -1
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/cli/config_spec.rb +54 -1
- data/spec/mysql/cli/ridgepole_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e81708c1fcd99a721354e49bdd8281e42657271da21acd80ecbf87e5a6b51890
|
4
|
+
data.tar.gz: d4d2321cfc763a9f23bd9e3d57e16ef5e07c852653e198286ef9d39ef16275b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55bf02b0f28ea259810c140697def6312f937e14cfc023be4aa6da75699844fd654b6d519896691ee1ddf7d1e2c60a12630d3820ce7e5e3505f210f400b02726
|
7
|
+
data.tar.gz: cd121f6363ffb2136a124990c9f373f984a634302d0e8633cfe2f9fc164e0e244eaf0997d52bdd4c3aa618e28b02593f755b8e6485a87dc0b6aba023a3237d45
|
data/.rubocop.yml
CHANGED
@@ -6,7 +6,7 @@ AllCops:
|
|
6
6
|
Bundler/OrderedGems:
|
7
7
|
Include:
|
8
8
|
- 'Appraisals'
|
9
|
-
Layout/
|
9
|
+
Layout/HeredocIndentation:
|
10
10
|
Enabled: false
|
11
11
|
Metrics/AbcSize:
|
12
12
|
Enabled: false
|
@@ -18,7 +18,7 @@ Metrics/ClassLength:
|
|
18
18
|
Enabled: false
|
19
19
|
Metrics/CyclomaticComplexity:
|
20
20
|
Enabled: false
|
21
|
-
|
21
|
+
Style/LineLength:
|
22
22
|
Enabled: false
|
23
23
|
Metrics/MethodLength:
|
24
24
|
Enabled: false
|
data/.travis.yml
CHANGED
@@ -4,11 +4,10 @@ group: edge
|
|
4
4
|
language: ruby
|
5
5
|
cache:
|
6
6
|
- bundler
|
7
|
-
- apt
|
8
7
|
rvm:
|
9
|
-
- 2.4.
|
10
|
-
- 2.5.
|
11
|
-
- 2.6.
|
8
|
+
- 2.4.9
|
9
|
+
- 2.5.7
|
10
|
+
- 2.6.5
|
12
11
|
before_script:
|
13
12
|
- sudo service mysql stop
|
14
13
|
- sudo service postgresql stop
|
@@ -41,7 +40,5 @@ addons:
|
|
41
40
|
- postgresql-client-9.4
|
42
41
|
matrix:
|
43
42
|
exclude:
|
44
|
-
- rvm: 2.
|
45
|
-
gemfile: gemfiles/activerecord_6.0.gemfile
|
46
|
-
- rvm: 2.4.6
|
43
|
+
- rvm: 2.4.9
|
47
44
|
gemfile: gemfiles/activerecord_6.0.gemfile
|
data/README.md
CHANGED
@@ -111,6 +111,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
111
111
|
* Display a warning if an InnoDB table doesn't have any indexes on a column where it has a foreign key ([pull#290](https://github.com/winebarrel/ridgepole/pull/290))
|
112
112
|
* `>= 0.8.5`
|
113
113
|
* Improve warning message on table options ([pull#291](https://github.com/winebarrel/ridgepole/pull/291))
|
114
|
+
* `>= 0.8.6`
|
115
|
+
* Support multiple databases feature ([pull#297](https://github.com/winebarrel/ridgepole/pull/297))
|
114
116
|
</details>
|
115
117
|
|
116
118
|
## Installation
|
@@ -152,6 +154,7 @@ sudo /opt/ridgepole/embedded/bin/gem install mysql2
|
|
152
154
|
Usage: ridgepole [options]
|
153
155
|
-c, --config CONF_OR_FILE
|
154
156
|
-E, --env ENVIRONMENT
|
157
|
+
-s, --spec-name SPEC_NAME
|
155
158
|
-a, --apply
|
156
159
|
-m, --merge
|
157
160
|
-f, --file SCHEMAFILE
|
data/bin/ridgepole
CHANGED
@@ -38,6 +38,7 @@ split = false
|
|
38
38
|
diff_files = nil
|
39
39
|
diff_with_apply = false
|
40
40
|
exit_code = 0
|
41
|
+
spec_name = ''
|
41
42
|
|
42
43
|
options = {
|
43
44
|
dry_run: false,
|
@@ -76,6 +77,7 @@ ARGV.options do |opt|
|
|
76
77
|
begin
|
77
78
|
opt.on('-c', '--config CONF_OR_FILE') { |v| config = v }
|
78
79
|
opt.on('-E', '--env ENVIRONMENT') { |v| env = v }
|
80
|
+
opt.on('-s', '--spec-name SPEC_NAME') { |v| spec_name = v }
|
79
81
|
opt.on('-a', '--apply') { set_mode[:apply] }
|
80
82
|
opt.on('-m', '--merge') do
|
81
83
|
set_mode[:apply]
|
@@ -168,7 +170,7 @@ begin
|
|
168
170
|
logger = Ridgepole::Logger.instance
|
169
171
|
logger.debug = options[:debug]
|
170
172
|
|
171
|
-
client = Ridgepole::Client.new(Ridgepole::Config.load(config, env), options) if config
|
173
|
+
client = Ridgepole::Client.new(Ridgepole::Config.load(config, env, spec_name), options) if config
|
172
174
|
|
173
175
|
ActiveRecord::Base.logger = logger
|
174
176
|
ActiveSupport::LogSubscriber.colorize_logging = options[:color]
|
@@ -247,7 +249,7 @@ begin
|
|
247
249
|
file_ext = File.extname(diff_file)
|
248
250
|
|
249
251
|
if %w[.yml .yaml].include?(file_ext)
|
250
|
-
Ridgepole::Config.load(diff_file, env)
|
252
|
+
Ridgepole::Config.load(diff_file, env, spec_name)
|
251
253
|
else
|
252
254
|
File.open(diff_file)
|
253
255
|
end
|
data/lib/ridgepole/cli/config.rb
CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
|
|
6
6
|
module Ridgepole
|
7
7
|
class Config
|
8
8
|
class << self
|
9
|
-
def load(config, env = 'development')
|
9
|
+
def load(config, env = 'development', spec_name = '')
|
10
10
|
config = ENV.fetch(Regexp.last_match(1)) if config =~ /\Aenv:(.+)\z/
|
11
11
|
|
12
12
|
parsed_config = if File.exist?(config)
|
@@ -26,8 +26,10 @@ module Ridgepole
|
|
26
26
|
|
27
27
|
parsed_config = parse_database_url(config) unless parsed_config.is_a?(Hash)
|
28
28
|
|
29
|
-
if parsed_config.key?(env.to_s)
|
30
|
-
|
29
|
+
parsed_config = parsed_config.fetch(env.to_s) if parsed_config.key?(env.to_s)
|
30
|
+
|
31
|
+
if parsed_config.key?(spec_name.to_s)
|
32
|
+
parsed_config.fetch(spec_name.to_s)
|
31
33
|
else
|
32
34
|
parsed_config
|
33
35
|
end
|
data/lib/ridgepole/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Ridgepole::Config do
|
4
|
-
subject { Ridgepole::Config.load(config, env) }
|
4
|
+
subject { Ridgepole::Config.load(config, env, spec_name) }
|
5
|
+
|
6
|
+
let(:spec_name) { '' }
|
5
7
|
|
6
8
|
context 'when passed toplevel yaml' do
|
7
9
|
let(:config) do
|
@@ -154,4 +156,55 @@ describe Ridgepole::Config do
|
|
154
156
|
expect(subject['port']).to eq 3307
|
155
157
|
}
|
156
158
|
end
|
159
|
+
|
160
|
+
context 'when passed rails database.yml multiple databases style yaml' do
|
161
|
+
let(:config) do
|
162
|
+
<<-YAML.strip_heredoc
|
163
|
+
development:
|
164
|
+
primary:
|
165
|
+
adapter: sqlspecifye
|
166
|
+
database: db/sample.db
|
167
|
+
production:
|
168
|
+
primary:
|
169
|
+
adapter: mysql2
|
170
|
+
encoding: utf8
|
171
|
+
database: blog
|
172
|
+
username: root
|
173
|
+
primary_replica:
|
174
|
+
adapter: mysql2
|
175
|
+
encoding: utf8
|
176
|
+
database: blog
|
177
|
+
username: readonly
|
178
|
+
YAML
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'in development env with primary spec name' do
|
182
|
+
let(:env) { 'development' }
|
183
|
+
let(:spec_name) { 'primary' }
|
184
|
+
specify do
|
185
|
+
expect(subject['adapter']).to eq 'sqlspecifye'
|
186
|
+
expect(subject['database']).to eq 'db/sample.db'
|
187
|
+
expect(subject['username']).to be_nil
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'in production env with primary spec name' do
|
192
|
+
let(:env) { 'production' }
|
193
|
+
let(:spec_name) { 'primary' }
|
194
|
+
specify do
|
195
|
+
expect(subject['adapter']).to eq 'mysql2'
|
196
|
+
expect(subject['encoding']).to eq 'utf8'
|
197
|
+
expect(subject['database']).to eq 'blog'
|
198
|
+
expect(subject['username']).to eq 'root'
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context 'in production env with primary_replica spec name' do
|
203
|
+
let(:env) { 'production' }
|
204
|
+
let(:spec_name) { 'primary_replica' }
|
205
|
+
specify do
|
206
|
+
expect(subject['username']).to eq 'readonly'
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
157
210
|
end
|
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.8.
|
4
|
+
version: 0.8.6
|
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: 2020-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|