aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-01-16 03:54:15 +0000
committerMichael Koziarski <michael@koziarski.com>2008-01-16 03:54:15 +0000
commit61e550ade937f812546b6fe561bc5ceb4460b9fb (patch)
tree41e48bceb97c612a694ec91cbbaa089c71e1b1d9 /activerecord/lib/active_record
parentb812b236876ab7a6bd1f3e58a1aa71847394f3a1 (diff)
downloadrails-61e550ade937f812546b6fe561bc5ceb4460b9fb.tar.gz
rails-61e550ade937f812546b6fe561bc5ceb4460b9fb.tar.bz2
rails-61e550ade937f812546b6fe561bc5ceb4460b9fb.zip
Don't ignore :precision and :scale when adding columns on postgresql. Closes #6868 [w.piekutowski]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8647 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 60e258c76a..6b2e5d21c4 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -587,13 +587,14 @@ module ActiveRecord
execute "ALTER TABLE #{name} RENAME TO #{new_name}"
end
- # Adds a column to a table.
+ # Adds a new column to the named table.
+ # See TableDefinition#column for details of the options you can use.
def add_column(table_name, column_name, type, options = {})
default = options[:default]
notnull = options[:null] == false
# Add the column.
- execute("ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit])}")
+ execute("ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quoted_column_name} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}")
change_column_default(table_name, column_name, default) if options_include_default?(options)
change_column_null(table_name, column_name, false, default) if notnull