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

 

Donate-Button

Help to do more!

The content you read is available for free. If you’ve liked any of the articles at this site, please take a second to help us write more and more articles based on real experiences and maintain them for you and others. Your support will make it possible for us.

$10.00

Let me know your thoughts