Methods:
create_table(name, options)
drop_table(name)
rename_table(old_name, new_name)
add_column(table_name, column_name, type, options)
rename_column(table_name, column_name, new_column_name)
change_column(table_name, column_name, type, options)
remove_column(table_name, column_name)
add_index(table_name, column_name, index_type)
remove_index(table_name, column_name)
Rake Tasks:
rake -T
Example Migration:
class UpdateUsersAndCreateProducts < ActiveRecord::Migration
def self.up
rename_column "users", "password", "hashed_password"
remove_column "users", "email"
create_table "products", :force => true do |t|
t.column "name", :text
t.column "description", :text
end
end
def self.down
rename_column "users", "hashed_password", "password"
add_column "users", "email"
drop_table "products"
end
endcheat sheets.
$ cheat migrations( add new | see all )
- updated sheets

- mysql_select
- cheat
- cryptsetup
- burm
- perl
- port
- yuilang
- queriac
- mechanize
- sness
- nonsense
- haml
- git
- assert_valid
- marsmission
Advertisement