Active Record tracks which migrations have already been run so all you have to do is update your source and run rake db:migrate. Active Record will work out which migrations should be run. It will also update your db/schema.rb file to match the structure of your database.
-
migrations for schema creation
-
validations
-
one-to-may association
-
many-to-many association
-
spec tests
-
Schema
-
Associations
-
Migrations
- symmetric
-
TDD models and migrations
-
Scrub and import data
-
AR queries
-
internalize schema
class AddCanFireMissilesFlagToUsers < ActiveRecord::Migration
def change
add_column :users, :can_fire_missiles, :boolean, :default => false
end
end
- binary
- boolean
- date
- datetime
- decimal
- float
- integer
- primary_key
- string
- text
- time
- timestamp
Active Record provides methods that perform common data definition tasks in a database independent way:
- add_column
- add_index
- change_column
- change_table
- create_table
- drop_table
- remove_column
- remove_index
- rename_column