Show Menu
Cheatography

Rails 3 Migrations Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Creating Migration

rails g model [name] [options]
rails g migration Add[na­me]­To[­table] [options]
rails g migration Remove­[na­me]­Fro­m[t­able] [options]
 

Rake Tasks

db:create
db:migrate [VERSI­ON=#]
db:mig­rat­e:redo [STEP=#]
db:mig­rate:up [VERSI­ON=#]
db:rol­lback [STEP=#]
db:reset
db:drop
db:seed
 

Supported Types

binary
boolean
date
datetime
decimal
float
integer
primar­y_key
string
text
time
timestamp
You can create your own types not supported by rails:
t.column :name, 'typeHere'