When trying to set up Solid Queue in a new Rails 8 project, I followed what seemed like the obvious steps:
- Created a new Rails 8 project
- Ran
rails db:migrate
- Tried to start Solid Queue with
rails solid_queue:start
However, I kept getting this error:
ActiveRecord::StatementInvalid: Could not find table 'solid_queue_processes'
Even after running migrations, the necessary tables weren’t being created. What gives?
The Solution
It turns out that the key to getting Solid Queue working in Rails 8 is to set it up similar to how you would in production, with separate databases for different concerns (data, cache, queue, etc.).
- First configure your
config/database.yml
to include a separate queue database:
development:
primary:
<<: *default
database: storage/development.sqlite3
queue:
<<: *default
database: storage/development_queue.sqlite3
migrations_paths: db/queue_migrate
- Now run
rails db:migrate
and this will create all the tables in queue database - Lastly, point Solid Queue to the new database by adding the following lines into
environments/development.rb
config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = { database: { writing: :queue } }
This explicitly tells Solid Queue which database to use for its operations.
Start Job Processing
Finally start queue processing by running:
bin/jobs start
Happy queueing! 😀