How can I create a production database in Rails 3 and load a schema to it?
I tried the following approaches...
I.
rake db:create Rails.env='production' && rake db:schema:load Rails.env='production'
II.
# config/environment.rb # Set the rails environment Rails.env='production' rake db:create && rake db:schema:load
... but neither of them works.
Thanks.
Debian GNU/Linux 5.0.6;
Rails 3.0.0;
Sqlite3 3.7.2.
The production environment is used when you deploy your application for the world to use. Rails comes with built-in support for SQLite, which is a lightweight serverless database application. While a busy production environment may overload SQLite, it works well for development and testing.
Ruby on Rails recommends to create three databases - a database each for development, testing, and production environment. According to convention, their names should be − You should initialize all three of them and create a user and password for them with full read and write privileges.
If you want to create just the animals database you can run bin/rails db:create:animals. Migrations for multiple databases should live in their own folders prefixed with the name of the database key in the configuration. You also need to set the migrations_paths in the database configurations to tell Rails where to find the migrations.
While Rails tries to do most of the work for you there are still some steps you'll need to do to get your application ready for multiple databases. Let's say we have an application with a single writer database and we need to add a new database for some new tables we're adding.
You can set the rails env off of the environment variable RAILS_ENV
RAILS_ENV=production bundle exec rake db:create db:schema:load
should work
Shouldn't this be
RAILS_ENV=production bundle exec rake db:create db:schema:load
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With