solid_queue: Having Problems configuring solid_queue DB
Apologies if this question has already been asked but I can’t find the right way to set up the solid_queue db alongside my primary db. Every time I try to start tsolid_queue I keep getting the error below, I’m all new when it comes to using multiple DBs and I’m here to learn:
bundle exec rake solid_queue:start rake aborted! ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "solid_queue_processes" does not exist LINE 10: WHERE a.attrelid = '"solid_queue_processes"'::regclass
This is my database.yml file setup:
`default: &default adapter: postgresql pool: <%= ENV.fetch(“RAILS_MAX_THREADS”) { 5 } %> timeout: 5000
development: primary: <<: *default database: msangia_development queue: <<: *default database: msangia_queue_dev migrations_paths: db/queue_migrate test: <<: *default database: msangia_wifi_test
production: primary: <<: *default database: msangia_wifi_production queue: <<: *default database: app_production_queue migrations_paths: db/queue_migrate`
development.rb environment:
`config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = { database: { writing: :queue } }`
The queue_schema.rb is created, but every time I run rails:db prepare, it’s cleared, and nothing happens after. I did run the migrations on my terminal, but I’m still getting the same error when I try to start solid_queue. I created the queue_migrate, copied the queue_schema into it, and tried migrating it, but I’m still getting the same error.
I would appreciate any help, thanks in prior.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 18 (6 by maintainers)
When running
rails solid_queue:install, it creates schema file only and doesn’t generate the migration. After running commands like:rails db:preparethe schema is reset because the migration is missing.I solved it by manually creating the migration:
rails generate migration CreateQueueTable --database=queueIt will create a regular migration into
db/queue_migratefolder. Copy the content ofqueue_schema.rb.Now you can run
rails db:prepareand it will work for both development and production.Note: remember to add
database.ymlconfig, as mentioned by @sevinchekI was able to fix this error by running
rails db:preparein development so I guess that part is really important for solid queue as I didn’t see any migration files being added only updates to the schemaYes, I had the same issue. (tested with 7.2 and 8.0.0.rc2)
first make sure the schema is really loaded into the db. In my case I checked with “DB Browser for SQLite” and saw that it’s missing all the tables.
Then I had to add the storage config also to the
testenv (indatabase.yml).actually
rails db:reset:queuegives a hint, when you don’t have it configured for test:So this is the complete change I made after rails new:
hope that helps 😃
I am using Rails 8 and I have
solid_queueworking in development. After creating the project I ran:bin/rails db:setupbin/rails db:migrateand made these configurations:
Oh, I see, that’s wrong. The instructions here are the correct ones. I’ll open a PR in the Rails guides to fix this.
As long as you’re running
db:prepare, the DB should get populated with the tables because these live inqueue_schema.rb. You don’t need migrations.