Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple DBs with different sets of migrations #43

Open
ariaru opened this issue Oct 27, 2021 · 1 comment
Open

Support for multiple DBs with different sets of migrations #43

ariaru opened this issue Oct 27, 2021 · 1 comment

Comments

@ariaru
Copy link

ariaru commented Oct 27, 2021

Hi,

we’d love to use handcuffs with our application, and are currently trying to set it up.
Our application connects to two DBs, with different sets of migrations. When trying to run handcuffs' rake tasks, e.g. bundle exec rake 'handcuffs:migrate[pre_restart]' --trace, I get

** Invoke handcuffs:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute handcuffs:migrate
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
rake aborted!
LoadError: cannot load such file -- db/migrate_other/20211026195842_create_handcuffs_other_tests.rb
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/handcuffs/phase_filter.rb:25:in `block in proxies_with_migrations'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/handcuffs/phase_filter.rb:24:in `map'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/handcuffs/phase_filter.rb:24:in `proxies_with_migrations'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/handcuffs/phase_filter.rb:11:in `filter'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/tasks/handcuffs.rake:42:in `runnable'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1302:in `migrate_without_lock'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1251:in `block in migrate'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1401:in `block in with_advisory_lock'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1416:in `block in with_advisory_lock_connection'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1416:in `with_advisory_lock_connection'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1397:in `with_advisory_lock'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1251:in `migrate'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1086:in `up'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:1061:in `migrate'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:90:in `each'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/tasks/handcuffs.rake:35:in `run_task'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/handcuffs-1.4.1/lib/tasks/handcuffs.rake:5:in `block (2 levels) in <main>'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `block in execute'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `each'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `execute'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/<...>/.asdf/installs/ruby/2.7.2/bin/rake:23:in `load'
/home/<...>/.asdf/installs/ruby/2.7.2/bin/rake:23:in `<top (required)>'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:63:in `load'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:63:in `kernel_load'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:28:in `run'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/cli.rb:494:in `exec'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/cli.rb:30:in `dispatch'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/cli.rb:24:in `start'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/exe/bundle:49:in `block in <top (required)>'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
/home/<...>/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.17/exe/bundle:37:in `<top (required)>'
/home/<...>/.asdf/installs/ruby/2.7.2/bin/bundle:23:in `load'
/home/<...>/.asdf/installs/ruby/2.7.2/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate

You can find the sample app that reproduces the issue (that the stack trace above is taken from) here: https://github.com/ariaru/test2dbs

We did experiment with auto loading and eager loading, but ran into issues with Zeitwerk: it complains about
migration constants starting with numbers (the timestamps).

Would you have any pointers as to how to fix this, or have you considered adding support for multiple DBs?

Thanks a lot!

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
@lessthanjacob lessthanjacob reopened this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants