Skip to content

Instantly share code, notes, and snippets.

@sameera207
Created December 18, 2012 07:32
Show Gist options
  • Save sameera207/4325854 to your computer and use it in GitHub Desktop.
Save sameera207/4325854 to your computer and use it in GitHub Desktop.
ROR migration cheat cheet
(ActiveRecord::Migration)
=== migration options
add_column
add_index
change_column
change_table
create_table
drop_table
remove_column
remove_index
rename_column
=== suported data types
:binary
:boolean
:date
:datetime
:decimal
:float
:integer
:primary_key
:string
:text
:time
:timestamp
=== create migration
rails generate model Product name:string description:text
=== references
create_table :products do |t|
t.references :category
end
=== running a specific version of a migration
rake db:migrate VERSION=20080906120000
=== rollback migration
rake db:rollback
rake db:rollback STEP=3
rake db:migrate:up VERSION=20080906120000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment