Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake db:create vs rake db:create:all

What is the difference between rake db:create and rake db:create:all?
Both are equally used in order to create a database for a Rails application.
The most exhaustive information on rake for Rails I could find is at tutorialpoint but the above commands are missing.

like image 476
Asarluhi Avatar asked Feb 25 '16 18:02

Asarluhi


3 Answers

  • rake db:create:all creates all the databases for the application (which are defined in database.yml)
  • rake db:create creates the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases.

FYI: http://jacopretorius.net/2014/02/all-rails-db-rake-tasks-and-what-they-do.html

like image 122
Jefferson Avatar answered Oct 16 '22 13:10

Jefferson


One creates the DB for the current environment.

One creates the DB for all environments.

like image 2
Dave Newton Avatar answered Oct 16 '22 12:10

Dave Newton


If you run rake -T | grep db, you will see :

rake db:create 
# Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV
# (use db:create:all to create all databases in the config)
like image 2
Arup Rakshit Avatar answered Oct 16 '22 12:10

Arup Rakshit