migration path not respected when setting up solid_queue on separate database?
Opened this issue ยท 4 comments
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!
@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?
@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
Ahhh, great to know, I wasn't sure. Thanks a lot for checking that, @dianacamacho ๐
Sorry for the long delay ๐ doc PR opened here: #225