I believe you set this using the RAILSENV=production parameter for rake,
and that the default is development. I cannot find reference to this
specifically at the moment - if anyone can point me to a link
documenting the use of RAILSENV I will really appreciate it.
The command that I have used is:
rake db:migrate RAILSENV=production when migrating to production
environment.
Happily, rake went to the development database both to dump the schema and
add the schema_info table.
Question: How did rake decide to use that database rather than test or
production?
Is it because development is specified first in the yml file?
Is it because development is the only one with tables?
Is it because there's a setting somewhere that defaults to development but
can be modified to target other databases?
Rails defaults to the development environment (and therefore the
development database). You can switch to production by setting the
RAILS_ENV environment variable to 'production'. The test evironment is
used automatically for running testcases.
You can, however, specify additional database connections in
database.yml, and explicitly tell activerecord to use these:
class FromOtherDb < ActiveRecord::Base
establish_connection configurations['otherdb']
end