List columns within the method (#11377)
To avoid the exception: NoMethodError: undefined method `perform' for nil:NilClass .../vendor/bundle/ruby/2.6.0/gems/strong_migrations-0.4.1/lib/strong_migrations/migration.rb:14:in `method_missing' .../vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/migration.rb:604:in `method_missing' .../db/migrate/20170918125918_ids_to_bigints.rb:69:in `<class:IdsToBigints>' .../db/migrate/20170918125918_ids_to_bigints.rb:3:in `<top (required)>'gh/stable
parent
24367ef906
commit
cd68714393
|
@ -5,7 +5,8 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||||
|
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
INCLUDED_COLUMNS = [
|
def migrate_columns(to_type)
|
||||||
|
included_columns = [
|
||||||
[:account_domain_blocks, :account_id],
|
[:account_domain_blocks, :account_id],
|
||||||
[:account_domain_blocks, :id],
|
[:account_domain_blocks, :id],
|
||||||
[:accounts, :id],
|
[:accounts, :id],
|
||||||
|
@ -66,9 +67,8 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||||
[:web_settings, :id],
|
[:web_settings, :id],
|
||||||
[:web_settings, :user_id],
|
[:web_settings, :user_id],
|
||||||
]
|
]
|
||||||
INCLUDED_COLUMNS << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
||||||
|
|
||||||
def migrate_columns(to_type)
|
|
||||||
# Print out a warning that this will probably take a while.
|
# Print out a warning that this will probably take a while.
|
||||||
say ''
|
say ''
|
||||||
say 'WARNING: This migration may take a *long* time for large instances'
|
say 'WARNING: This migration may take a *long* time for large instances'
|
||||||
|
@ -86,7 +86,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
|
|
||||||
tables = INCLUDED_COLUMNS.map(&:first).uniq
|
tables = included_columns.map(&:first).uniq
|
||||||
table_sizes = {}
|
table_sizes = {}
|
||||||
|
|
||||||
# Sort tables by their size
|
# Sort tables by their size
|
||||||
|
@ -94,7 +94,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||||
table_sizes[table] = estimate_rows_in_table(table)
|
table_sizes[table] = estimate_rows_in_table(table)
|
||||||
end
|
end
|
||||||
|
|
||||||
ordered_columns = INCLUDED_COLUMNS.sort_by do |col_parts|
|
ordered_columns = included_columns.sort_by do |col_parts|
|
||||||
[-table_sizes[col_parts.first], col_parts.last]
|
[-table_sizes[col_parts.first], col_parts.last]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue