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

migration path not respected when setting up solid_queue on separate database? #144

Open
dianacamacho opened this issue Feb 6, 2024 · 4 comments

Comments

@dianacamacho
Copy link

dianacamacho commented Feb 6, 2024

Firstly, thank you for all the work on solid queue so far!

Apologies if this is lack of understanding and user-error on my part, but when the docs mention supporting solid queue on a different database than the main app (via connects_to), does that mean that the install/migration commands should automatically pick up on the settings I've defined in my app's config/database.yml for the given connects_to database key, or do I still need to manually tell solid queue which one to use when running those?

Currently, with the config and database.yml settings listed below for a separate :solid_queue db, when I run bin/rails generate solid_queue:install or bin/rails solid_queue:install:migrations, the migration files for the SolidQueue tables are copied to the db/migrate folder, resulting in the tables getting added to the :primary db instead of the :solid_queue one. However, I would have expected the install to copy them to db/solid_queue_migrate, to match the migrations_paths defined in database.yml for the solid_queue db)

# config/application.rb

config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = { database: { writing: :solid_queue, reading: :solid_queue } }
# config/database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

solid_queue: &solid_queue
  <<: *default
  migrations_paths: db/solid_queue_migrate

development:
  primary:
    <<: *default
    database: queue_demo_development
  solid_queue:
    <<: *solid_queue
    database: queue_demo_solid_queue_development

test:
  primary:
    <<: *default
    database: queue_demo_test

production:
  primary:
    <<: *default
  solid_queue:
    <<: *solid_queue
    url: <%= ENV["SOLID_QUEUE_DATABASE_URL"] %>

If I manually pass in the DATABASE as an arg to the migration command (bin/rails solid_queue:install:migrations DATABASE=solid_queue), then things do work as expected, with files copied to db/solid_queue_migrate and added to the solid_queue db). If this is how it's meant to work, maybe that can be made a little clearer in the docs. Thanks!

@rosa
Copy link
Member

rosa commented Feb 13, 2024

@dianacamacho, thank you so much for this detailed and carefully written issue! You're spot on, DATABASE=solid_queue (or I think --database solid_queue works as well, but I haven't tested it) is how this should be used.

Would you like to submit a PR to include this in the README?

@dianacamacho
Copy link
Author

@rosa sure! i'll get that added to a PR. thanks!

re: --database solid_queue, i also tried that out at first but it returned invalid option: --database 🤔 . it didn't work unless i passed the db option as DATABASE=solid_queue

@rosa
Copy link
Member

rosa commented Feb 14, 2024

Ahhh, great to know, I wasn't sure. Thanks a lot for checking that, @dianacamacho 🙏

@dianacamacho
Copy link
Author

Sorry for the long delay 🙈 doc PR opened here: #225

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