mirror of
https://github.com/github/rails.git
synced 2026-01-29 16:28:09 -05:00
MySQL: change_column raises if the table or column doesn't exist.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7665 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -408,7 +408,11 @@ module ActiveRecord
|
||||
|
||||
def change_column(table_name, column_name, type, options = {}) #:nodoc:
|
||||
unless options_include_default?(options)
|
||||
options[:default] = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")["Default"]
|
||||
if result = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")
|
||||
options[:default] = result['Default']
|
||||
else
|
||||
raise "No such column: #{table_name}.#{column_name}"
|
||||
end
|
||||
end
|
||||
|
||||
change_column_sql = "ALTER TABLE #{table_name} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
|
||||
|
||||
Reference in New Issue
Block a user