Skip to content

Commit

Permalink
Merge pull request #254 from winebarrel/fix_for_rubocop
Browse files Browse the repository at this point in the history
Fix for rubocop new rules
  • Loading branch information
winebarrel committed Sep 29, 2018
2 parents 3f9a231 + 1500ca7 commit 9cdc806
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/ridgepole
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ options = {

set_mode = proc do |m|
raise OptionParser::InvalidOption, 'More than one mode is specified' if mode

mode = m
end

Expand Down Expand Up @@ -85,6 +86,7 @@ ARGV.options do |opt|
opt.on('', '--external-script SCRIPT') { |v| options[:external_script] = v }
opt.on('', '--bulk-change') do
raise OptionParser::InvalidOption, 'Cannot use `bulk-change` in `merge`' if options[:merge]

options[:bulk_change] = true
end

Expand Down
6 changes: 6 additions & 0 deletions lib/ridgepole/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def scan_table_rename(from, to, delta, _options = {})
next unless target?(table_name)

next unless (from_table_name = (to_attrs[:options] || {}).delete(:renamed_from))

from_table_name = from_table_name.to_s if from_table_name

# Already renamed
Expand Down Expand Up @@ -197,6 +198,7 @@ def build_primary_key_attrs_if_changed(from, to, table_name)
from_column_attrs = convert_to_primary_key_attrs(from.slice(*PRIMARY_KEY_OPTIONS))
to_column_attrs = convert_to_primary_key_attrs(to.slice(*PRIMARY_KEY_OPTIONS))
return if from_column_attrs == to_column_attrs

build_attrs_if_changed(to_column_attrs, from_column_attrs, table_name, primary_key: true)
end

Expand Down Expand Up @@ -254,6 +256,7 @@ def scan_definition_change(from, to, from_indices, table_name, table_options, ta
definition_delta[:delete][column_name] = from_attrs

next unless from_indices

modified_indices = []

from_indices.each do |name, attrs|
Expand Down Expand Up @@ -281,6 +284,7 @@ def scan_definition_change(from, to, from_indices, table_name, table_options, ta
def scan_column_rename(from, to, definition_delta)
to.dup.each do |column_name, to_attrs|
next unless (from_column_name = (to_attrs[:options] || {}).delete(:renamed_from))

from_column_name = from_column_name.to_s if from_column_name

# Already renamed
Expand Down Expand Up @@ -556,6 +560,7 @@ def scan_relation_info(relation_info)
end

next unless parent_column_info != child_column_info

parent_label = "#{parent_table}.id"
child_label = "#{child_table}.#{column_name}"
label_len = [parent_label.length, child_label.length].max
Expand All @@ -571,6 +576,7 @@ def scan_relation_info(relation_info)

def check_table_existence(definition)
return unless @options[:tables]

@options[:tables].each do |table_name|
@logger.warn "[WARNING] '#{table_name}' definition is not found" unless definition.key?(table_name)
end
Expand Down
1 change: 1 addition & 0 deletions lib/ridgepole/dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def dump
if target_tables
conn.data_sources.each do |tbl|
next if target_tables.include?(tbl)

ActiveRecord::SchemaDumper.ignore_tables << tbl
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/ridgepole/external_sql_executer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ def execute(sql)
ready = IO.select(files)

next unless ready

readable = ready[0]

readable.each do |f|
begin
data = f.read_nonblock(1024)
next if data.nil?

data.chomp!

if f == stderr
Expand Down

0 comments on commit 9cdc806

Please sign in to comment.