Show Menu
Cheatography

ActiveRecord::Migrations Cheat Sheet (DRAFT) by

Active Record Migrations

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

Migration Code Structure

class DoSmthWithSmth < ActiveRecord::Migration
  def change
    method :table_name, *args
    ...
    method :table_name, *args
  end
end

Available methods

add_column
:products, :name, :int
add_index
:products, :name
add_re­ference
add_ti­mes­tamps
create­_table
:products do |t|; code; end
create­_jo­in_­table
remove­_ti­mes­tamps
drop_table
:products
drop_j­oin­_table
change­_column
:products, :name, :string
change­_table
:products do |t|; code; end
remove­_column
:products, :name
rename­_index
:products, :name
rename­_column
:products, :name, :age
remove­_re­ference
rename­_table