After the table creation, I want to rearrange its fields in a different order, and take care about its stored data.
Is there any way to do this?
After the table creation, I want to rearrange its fields in a different order, and take care about its stored data.
Is there any way to do this?
You have to create a separate migration to change column.
rails g migration change_data_type_for_fieldname
class ChangeDataTypeForFieldname < ActiveRecord::Migration
def up
#change column type form int to bigint
change_column :my_table, :my_column, :bigint
end
def down
#change column type form bigint to int
change_column :my_table, :my_column, :int
end
end
Please refer api
You can use after in a change column statement: