Skip to content

Instantly share code, notes, and snippets.

@hsuh
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsuh/e93f06377a2c82d12897 to your computer and use it in GitHub Desktop.
Save hsuh/e93f06377a2c82d12897 to your computer and use it in GitHub Desktop.
rake db tasks
db:create creates the database for the current env
db:create:all creates the databases for all envs
db:drop drops the database for the current env
db:drop:all drops the databases for all envs
db:migrate runs migrations for the current env that have not run yet
db:migrate:up runs one specific migration
db:migrate:down rolls back one specific migration
db:migrate:status shows current migration status
db:migrate:rollback rolls back the last migration
db:forward advances the current schema version to the next one
db:seed (only) runs the db/seed.rb file
db:schema:load loads the schema into the current env's database
db:schema:dump dumps the current env's schema (and seems to create the db as well)
db:setup runs db:schema:load, db:seed
db:reset runs db:drop db:setup
db:migrate:redo runs (db:migrate:down db:migrate:up) or (db:migrate:rollback db:migrate:migrate) depending on the specified migration
db:migrate:reset runs db:drop db:create db:migrate
Parallel
rake parallel:drop
rake parallel:create
rake parallel:prepare
$ RAILS_ENV=test parallel_test -e "rake db:activate_hstore"
For further information please have a look at https://github.com/rails/rails/blob/v3.2.12/activerecord/lib/active_record/railties/databases.rake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment