I'm developing a Rails application in which I will use 2 different databases. Namely one for storing user credentials and another one for storing other type of data. I've setup my database.yml file to accept 2 different databases, for each environment. It looks like this:
<% %w(development test production).each do |env| %>
data_<%= env %>:
adapter: sqlite3
database: db/data/<%= env %>.sqlite3
pool: 5
timeout: 5000
users_<%= env %>:
adapter: sqlite3
database: db/users/<%= env %>.sqlite3
pool: 5
timeout: 5000
<% end %>
I also created to 2 level models, one for each database connection, namely:
class UsersBase < ActiveRecord::Base
establish_connection "users_#{RAILS_ENV}"
end
and
class DataBase < ActiveRecord::Base
establish_connection "data_#{RAILS_ENV}"
end
I've some issues while generating a model, because it couldn't find the standard "development" database but I've solved that by running the generate model with the --parent option set to the appropriate class.
However, now I have a problem while trying to run rake db:migrate. The rake task doesn't find the default development database (which is by convention should be named development in database.yml). My question is if it is possible to somehow supply this as a parameter to the rake task, or even better to signal Rails somewhere in the configuration script that there are 2 databases, or that the default name of the development database is changed?