Home
Ruby on Rails
Cheatsheets
|
db:create db:create:all |
Creates a single database specified in config/databases.yml for the current RAILS_ENV or creates all the databases |
|
db:drop db:drop:all |
Drops a single database specified in config/databases.yml for the current RAILS_ENV or drops all the databases |
|
db:fixtures:load |
Load fixtures from test/fixtures into the current environment's database |
|
db:migrate |
Run all unapplied migrations |
|
db:migrate:up db:migrate:down |
Move forward to the next migration, or back to the previous migration |
|
db:migrate VERSION=18 |
Migrate database to specific version |
|
db:migrate RAILS_ENV=production |
Use migrations to recreate tables in the testing or production databases |
|
db:schema:dump |
Create a db/schema.rb file that can be portably used against any database supported by ActiveRecord |
|
db:schema:load |
Load a schema.rb file into the database |
|
db:sessions:create |
Create a sessions table for use with CGI::Sessions::ActiveRecordStore |
|
db:sessions:clear |
Clear the sessions table |
|
db:structure:dump |
Dump database structure to SQL file |
|
db:reset |
Drops the database, creates the database and then runs migrations against the database. Takes a VERSION argument as well as RAILS_ENV |
|
db:rollback STEP=4 |
Takes a STEP argument to determine how many version to rollback, the default being one version |
|
db:test:prepare |
Clone your database structure into the test database |
|
db:version |
Tells you the current version your database is at |
A look at the new features and syntax available in migrations on Rails 2.0
More
A brilliant plugin that makes changing your database schema even easier and faster.
More