aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-11-24 14:15:45 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-11-24 14:15:56 -0800
commitfbef981fdc7ba64678f7ae1fc82b2cd790469280 (patch)
treed2d7f29e95e4ec3f2dc9a7063c8bf77c422eb18e /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
parent9f33e3daab02304e768e7391940fe29290f3c3bf (diff)
downloadrails-fbef981fdc7ba64678f7ae1fc82b2cd790469280.tar.gz
rails-fbef981fdc7ba64678f7ae1fc82b2cd790469280.tar.bz2
rails-fbef981fdc7ba64678f7ae1fc82b2cd790469280.zip
allow the "USING" statement to be specified on change column calls
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index 515ff2dd44..208302b365 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -433,7 +433,9 @@ module ActiveRecord
quoted_table_name = quote_table_name(table_name)
sql_type = type_to_sql(type, options[:limit], options[:precision], options[:scale])
sql_type << "[]" if options[:array]
- execute "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{sql_type}"
+ sql = "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{sql_type}"
+ sql << " USING #{options[:using]}" if options[:using]
+ execute sql
change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)
change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)