method
change_column
rails latest stable - Class:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::SchemaStatements
Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v4.1.8) is shown here.
change_column(table_name, column_name, type, options = {})public
Changes the column of a table.
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb, line 399
def change_column(table_name, column_name, type, options = {})
clear_cache!
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}"
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)
end Related methods
- Instance methods
- add_column
- add_index
- change_column
- change_column_default
- change_column_null
- client_min_messages
- client_min_messages=
- collation
- column_for
- columns
- columns_for_distinct
- create_database
- create_schema
- ctype
- current_database
- current_schema
- default_sequence_name
- drop_database
- drop_schema
- encoding
- index_name_exists?
- index_name_length
- indexes
- pk_and_sequence_for
- primary_key
- recreate_database
- remove_index!
- rename_column
- rename_index
- rename_table
- reset_pk_sequence!
- schema_exists?
- schema_names
- schema_search_path
- schema_search_path=
- serial_sequence
- table_exists?
- tables
- type_to_sql