Created
December 18, 2012 07:32
-
-
Save sameera207/4325854 to your computer and use it in GitHub Desktop.
ROR migration cheat cheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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