Most used rails commands with database

This is a new post for ruby on rails developers, it is about most used databases commands you will need during development and testing

  • rake db:migrate runs (pending) migrations that have not run yet.
  • rake db:create creates the database
  • rake db:drop deletes the database
  • rake db:seed loads the seed data from db/seeds.rb
  • rake db:schema:load creates tables and columns within the (existing) database following schema.rb
  • rake db:setup does db:create, db:schema:load, db:seed
  • rake db:reset drops and recreates the database from db/schema.rb for the current environment and loads the seeds
  • rake db:test:prepare prepares the testing database to match the development database, the data is empty
  • rake db:seed RAILS_ENV=test loads seed data from db/seed.rb into the testing environment

Here is the reference for other commands may be helpful databases.rake tasks

 

Advertisements

Let me know your thoughts