We are using the excellent multiple database support in a Sinatra app and it works perfect. The only thing that didn’t work out-of-the-box are the rake database tasks like
rake db:migrate. They stopped working after we implemented the multiple database support. With a small tweak in our code using a special
establish_connection that basically only passes in the
primary database part of the configuration it works as normal again.
After looking in the code I noticed there are various checks explicitly checking for the
Rails module to be present in
ActiveRecord::Tasks::DatabaseTasks which most likely are the cause. Some seem to be easily fixed by using the configuration options that you can provide when using these tasks like: rails/database_tasks.rb at main · rails/rails · GitHub where there is a reference to
Rails.env instead of using the
Some like the one in
setup_initial_database_yaml (rails/database_tasks.rb at main · rails/rails · GitHub) seem a bit harder to fix.
Is this something you are willing to support and would accept a PR for?