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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.