BartlomiejSkwira
6/12/2013 - 11:06 AM

Migrations

Migrations

#bigint/decimal (no limit)
add_column :table_name, :really_big_int, :decimal


#execute sql
def up
  execute <<-SQL
    SELECT ...
  SQL
end


ActiveRecord::Base.connection.execute(@sql)




#rollback migration specific one
rake db:migrate:down VERSION=20100905201547

#rollback 2 migrations back
rake db:rollback STEP=2

#coditional migration
Profile.reset_column_information
add_column(:profile, :url, :string) unless Profile.column_names.include?('url')