The application I work on uses two databases; one for ordinary data and one for a data warehouse. Both databases are developed as part of the application (i.e. as part of the same Rails project). All is fine at the ActiveRecord level (I'm using establish_connection to associate data warehouse specific models to the right database). However, as far as I can tell migration support for this scenario isn't quite there yet.
What I would like to be able to do is to have two separate sets of migrations, one for each database, so that I could specify (in database.yml) e.g.:
development:
adapter: postgresql
database: development
...
datawarehouse_development:
migrations: datawarehouse <-- alternate location for migrations
adapter: postgresql
database: dw_development
...
and then place all my "ordinary" migrations in db/migrate as usual, and all the data warehouse related migrations in db/migrate/datawarehouse. Provided that I also provide a datawarehouse_development.rb, I should then be able to apply the migrations by specifying the proper RAILS_ENV:
RAILS_ENV=datawarehouse_development rake db:migrate
Looking at database.rake it seems that all that is needed are two small changes so that it (1) passes a migrations path to ActiveRecord::Migrator#migrate that includes (if present) the 'migrations' value from the current RAILS_ENV and (2) includes any such migration set name in the name of the schema file used by db:schema:dump.
I'm sitting on a tiny patch which accomplishes this -- would it be of any interest?
Cheers
Jacob Lauemøller