instance method
add_column
Ruby on Rails 3.2.22.5
Since v2.2.3 Last seen in v3.2.22.5Signature
add_column(table_name, column_name, type, options = {})
Adds a new column to the named table. See TableDefinition#column for details of the options you can use.
Parameters
-
table_namereq -
column_namereq -
typereq -
optionsopt = {}
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 1017
def add_column(table_name, column_name, type, options = {})
clear_cache!
add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
add_column_options!(add_column_sql, options)
execute add_column_sql
end
Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 1017
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter