8

I have searched for how to create db in production environment for rails and got 2 answers. Now I am confused with those answers.

RAILS_ENV=production rake db:create db:schema:load
RAILS_ENV=production rake db:create

What is the difference between these two? What does this schema means?

Why do we need db:schema:load?

Thanks in advance.

Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145
Anna
  • 973
  • 4
  • 13
  • 26
  • Possible duplicate of [Difference between rake db:migrate db:reset and db:schema:load](http://stackoverflow.com/questions/10301794/difference-between-rake-dbmigrate-dbreset-and-dbschemaload) – mlt Jun 02 '16 at 20:42

1 Answers1

9

RAILS_ENV=production rake db:create would create the database for the production environment,

whereas

RAILS_ENV=production rake db:schema:load would create tables and columns within the database according the schema.rb for the production environment.

task :load => [:environment, :load_config] do
  ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
end

task :create => [:load_config] do
  ActiveRecord::Tasks::DatabaseTasks.create_current
end

Take a look at this file for complete info on the topic.

Matheus Portillo
  • 187
  • 3
  • 10
Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145