Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify building options hash in rename column method for mysql

  • Loading branch information...
commit c61eebd64e579b196678e79dfbc3285de61d3923 1 parent 9aa63b2
@carlosantoniodasilva carlosantoniodasilva authored
View
11 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -711,12 +711,13 @@ def change_column_sql(table_name, column_name, type, options = {})
end
def rename_column_sql(table_name, column_name, new_column_name)
- options = { name: new_column_name }
column = column_for(table_name, column_name)
-
- options[:default] = column.default
- options[:null] = column.null
- options[:auto_increment] = column.extra == "auto_increment"
+ options = {
+ name: new_column_name,
+ default: column.default,
+ null: column.null,
+ auto_increment: column.extra == "auto_increment"
+ }
current_type = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'", 'SCHEMA')["Type"]
schema_creation.accept ChangeColumnDefinition.new column, current_type, options
Please sign in to comment.
Something went wrong with that request. Please try again.