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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b49db08934182bd164f7910335dd04f3843e2e88c8593ab1d89f9bb4d0005d8
4
- data.tar.gz: ff49a0ada6cac848407838596d23d93d75714079c0e95528015c4fcb9b2e4f56
3
+ metadata.gz: e81708c1fcd99a721354e49bdd8281e42657271da21acd80ecbf87e5a6b51890
4
+ data.tar.gz: d4d2321cfc763a9f23bd9e3d57e16ef5e07c852653e198286ef9d39ef16275b4
5
5
  SHA512:
6
- metadata.gz: dc24b664af9f8dad9f6c6d21b6eeaa083ad915c42b63b58ce0b7b50386e11c3462b2f30f9819c80f03e5c2a682dadd5a980a355993e8c4e2c8f4a0dc06703242
7
- data.tar.gz: c40af5068b9ccbc226d9375b8b7501584a161bdc81554d6612e2c1135346f9dcdbe4a1371657e23bc6d9f70df795e67c8addc6a8b5db538ce658e3588ad3867c
6
+ metadata.gz: 55bf02b0f28ea259810c140697def6312f937e14cfc023be4aa6da75699844fd654b6d519896691ee1ddf7d1e2c60a12630d3820ce7e5e3505f210f400b02726
7
+ data.tar.gz: cd121f6363ffb2136a124990c9f373f984a634302d0e8633cfe2f9fc164e0e244eaf0997d52bdd4c3aa618e28b02593f755b8e6485a87dc0b6aba023a3237d45
@@ -6,7 +6,7 @@ AllCops:
6
6
  Bundler/OrderedGems:
7
7
  Include:
8
8
  - 'Appraisals'
9
- Layout/IndentHeredoc:
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
- Metrics/LineLength:
21
+ Style/LineLength:
22
22
  Enabled: false
23
23
  Metrics/MethodLength:
24
24
  Enabled: false
@@ -4,11 +4,10 @@ group: edge
4
4
  language: ruby
5
5
  cache:
6
6
  - bundler
7
- - apt
8
7
  rvm:
9
- - 2.4.6
10
- - 2.5.5
11
- - 2.6.3
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.3.8
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
@@ -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
@@ -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
- parsed_config.fetch(env.to_s)
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
@@ -41,7 +41,7 @@ module Ridgepole
41
41
  end
42
42
  end
43
43
  end
44
- rescue EOFError # rubocop:disable Lint/HandleExceptions
44
+ rescue EOFError # rubocop:disable Lint/SuppressedException
45
45
  # nothing to do
46
46
  end
47
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '0.8.5'
4
+ VERSION = '0.8.6'
5
5
  end
@@ -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
@@ -17,6 +17,7 @@ describe 'ridgepole' do
17
17
  expect(out).to match_fuzzy <<-MSG
18
18
  -c, --config CONF_OR_FILE
19
19
  -E, --env ENVIRONMENT
20
+ -s, --spec-name SPEC_NAME
20
21
  -a, --apply
21
22
  -m, --merge
22
23
  -f, --file SCHEMAFILE
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.5
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: 2019-10-26 00:00:00.000000000 Z
11
+ date: 2020-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord