lib/generators/declare_schema/migration/migrator.rb
# return a hash of column renames and modifies the passed arrays so
# that renamed columns are no longer listed as to_create or to_drop
return a hash of column renames and modifies the passed arrays so
that renamed columns are no longer listed as to_create or to_drop
return a hash of column renames and modifies the passed arrays so that renamed columns are no longer listed as to_create or to_drop
def extract_column_renames!(to_add, to_remove, table_name)
          if @renames
            to_rename = {}
            if (column_renames = @renames[table_name.to_sym])
              column_renames.each do |old_name, new_name|
                old_name = old_name.to_s
                new_name = new_name.to_s
                to_add.delete(new_name) or raise Error,
                  "Rename specified new name: #{new_name.inspect} but it was not in the `to_add` list for table #{table_name}"
                to_remove.delete(old_name) or raise Error,
                  "Rename specified old name: #{old_name.inspect} but it was not in the `to_remove` list for table #{table_name}"
                to_rename[old_name] = new_name
              end
            end
            to_rename
          elsif @ambiguity_resolver
            @ambiguity_resolver.call(to_add, to_remove, "column", "#{table_name}.")
          else
            raise Error, "Unable to resolve migration ambiguities in table #{table_name}"
          end
        end
def extract_column_renames! ( to_add , to_remove , table_name ) if @renames to_rename = { } if ( column_renames = @renames [ table_name . to_sym ] ) column_renames . each do | old_name , new_name | old_name = old_name . to_s new_name = new_name . to_s to_add . delete ( new_name ) or raise Error , "Rename specified new name: #{new_name.inspect} but it was not in the `to_add` list for table #{table_name}" to_remove . delete ( old_name ) or raise Error , "Rename specified old name: #{old_name.inspect} but it was not in the `to_remove` list for table #{table_name}" to_rename [ old_name ] = new_name end end to_rename elsif @ambiguity_resolver @ambiguity_resolver . call ( to_add , to_remove , "column" , "#{table_name}." ) else raise Error , "Unable to resolve migration ambiguities in table #{table_name}" end end
return a hash of column renames and modifies the passed arrays so
that renamed columns are no longer listed as to_create or to_drop
return a hash of column renames and modifies the passed arrays so that renamed columns are no longer listed as to_create or to_drop
# A hash of column renames has been provided
to_add
<not_specific>
to_remove
<not_specific>
table_name
<not_specific>