Rails "tasks" (commands)
List of the most common Rake tasks

  • Reminder: rake is a command line utility that is used to automate a variety of small tasks that ruby and rails developers have to do all the time. (For your history buff, the name is derived from the old C utility called “make” – “ruby make” -> “rake”)
  • Reminder: As of Rails 5, you can use rails as the prefix instead of rake
Getting a list of Rake “tasks”
  • rake -T # to get a list of all the more typical rake tasks
  • rake -T -A # show every single task
  • db:migrate runs migrations for the current env that have not run yet
  • db:create creates the database for the current env
  • db:seed (only) runs the db/seed.rb file
  • db:setup runs db:schema:load, db:seed
  • db:reset runs db:drop db:setup
  • db:migrate:reset runs db:drop db:create db:migrate
  • 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: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: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)