data-migrate: Does not work with Rails multiple databases
When I configure my Rails 6.1 app to use multiple databases (via built in functionality), data-migrate doesn’t work.
bin/rake data:schema:load
my-project/db/secondary_db_data_schema.rb doesn't exist yet. Run `rake data:migrate` to create it, then try again.
but running rake data:migrate
does not create it.
Is it a known limitation? Do you plan to support multiple databases?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 19 (13 by maintainers)
We have this same issue. Has anyone found a workaround?
edit: We were able to get this working with an initializer:
Hi folks, just wanted to provide an update, we had a call with @ngan and @wildmaples. They will help on gem development, particularly for multi-database support and/or rails 7.1 support. I’ve added them as contributors. Since v10 has introduced issues with many folks, we will need to roll it back. Thanks @chaunce for your contribution, we certainly appreciate your work but seems we’d need another approach to keep it usable for wider audience. This was a good learning experience for sure.
I will yank v10.0.x versions to avoid people picking up versions that are not working
Hi everyone,
I tend to agree with @chaunce on following the Rails approach for migrations to run on specific connections. It might sounds like an overkill, but should be more versatile. We all might have different database setups since Rails allows that, but it doesn’t mean that data_migrate should pick only one to support. As long as this gem claims that data migrations act like schema migrations, similar implementation seems reasonable.
However, regardless of the approach, I don’t mind some breaking changes as long as there is a clear upgrade path documented somewhere.
P.S. @ilyakatz We have situation similar to Gusto (maybe not that heavily using data migrations though) and as of version 10 data migrations stopped working for us completely. Hence my recent activity with some fixes.
@chaunce thanks, could you email me and we’ll coordinate with @wildmaples to set up a call
@ilyakatz the gem is trying to update the data_migrations table of the secondary database. the data migration is for the primary database. so the gem seems to be unaware that multiple databases can exist.