Creating a database in a production environment in rails

I was looking for how to create db in a working environment for rails and got 2 answers. Now I am confused by these answers.

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

What is the difference between the two? What does this circuit mean?

Why do we need db:schema:load ?

Thanks in advance.

+5
source share
1 answer

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

then

RAILS_ENV=production rake db:schema:load will create tables and columns in the database according to 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 

See this file for complete information on this topic.

+6
source

Source: https://habr.com/ru/post/1201607/


All Articles