Skip to content

Commit 0bf654b

Browse files
dianacamachorosa
authored andcommitted
readme update: dedicated database config
1 parent 82500a1 commit 0bf654b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,52 @@ When receiving a `QUIT` signal, if workers still have jobs in-flight, these will
145145

146146
If processes have no chance of cleaning up before exiting (e.g. if someone pulls a cable somewhere), in-flight jobs might remain claimed by the processes executing them. Processes send heartbeats, and the supervisor checks and prunes processes with expired heartbeats, which will release any claimed jobs back to their queues. You can configure both the frequency of heartbeats and the threshold to consider a process dead. See the section below for this.
147147

148+
149+
### Dedicated database configuration
150+
151+
Solid Queue can be configured to run on a different database than the main application.
152+
153+
Configure the `connects_to` option in `config/application.rb` or your environment config like so, where `:solid_queue` is the identifier for your dedicated Solid Queue database.
154+
155+
```ruby
156+
config.solid_queue.connects_to = { database: { writing: :solid_queue, reading: :solid_queue } }
157+
```
158+
159+
Add the dedicated database configuration to `config/database.yml`, differentiating between the main `:primary` database and the dedicated `:solid_queue` database. Make sure to include the `migrations_paths` for the solid queue database. This is where migration files for Solid Queue tables will reside.
160+
161+
```yml
162+
default: &default
163+
adapter: sqlite3
164+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
165+
timeout: 5000
166+
167+
solid_queue: &solid_queue
168+
<<: *default
169+
migrations_paths: db/solid_queue_migrate
170+
171+
development:
172+
primary:
173+
<<: *default
174+
database: storage/development.sqlite3
175+
solid_queue:
176+
<<: *solid_queue
177+
database: storage/development_solid_queue.sqlite3
178+
```
179+
180+
Install migrations and specify the dedicated database name with the `DATABASE` option. This will create the Solid Queue migration files in a separate directory, matching the value provided in `migrations_paths` in `config/database.yml`.
181+
182+
```bash
183+
$ bin/rails solid_queue:install:migrations DATABASE=solid_queue
184+
```
185+
186+
Note: If you've already run the solid queue install command (`bin/rails generate solid_queue:install`), the migration files will have already been generated under the primary database's `db/migrate/` directory. You can remove these files and keep the ones generated by the database-specific migration installation above.
187+
188+
Finally, run the migrations:
189+
190+
```bash
191+
$ bin/rails db:migrate
192+
```
193+
148194
### Other configuration settings
149195
_Note_: The settings in this section should be set in your `config/application.rb` or your environment config like this: `config.solid_queue.silence_polling = true`
150196

0 commit comments

Comments
 (0)