Skip to content

Commit 568d3b9

Browse files
authored
Add SQLite support in Ruby (#67)
Adds SQLite support in Ruby that's compatible with the main River project in the same way that Postgres is.
1 parent b14293f commit 568d3b9

19 files changed

Lines changed: 1338 additions & 395 deletions

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add SQLite support to the ActiveRecord and Sequel drivers, including current River JSONB storage, atomic bulk inserts, unique jobs, and notification-outbox writes. [PR #67](https://github.com/riverqueue/riverqueue-ruby/pull/67).
13+
14+
### Changed
15+
16+
- Stop pulling in `pg` as a hard dependency of either driver. Applications now select their database adapter by including `pg` for PostgreSQL or `sqlite3` for SQLite. [PR #67](https://github.com/riverqueue/riverqueue-ruby/pull/67).
17+
1018
## [0.10.1] - 2026-04-09
1119

1220
### Fixed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ end
99

1010
group :test do
1111
gem "debug"
12+
gem "pg"
1213
gem "rspec-core"
1314
gem "rspec-expectations"
1415
gem "riverqueue-sequel", path: "driver/riverqueue-sequel"
1516
gem "simplecov", require: false
17+
gem "sqlite3"
1618
end

Gemfile.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ PATH
77
remote: driver/riverqueue-sequel
88
specs:
99
riverqueue-sequel (0.10.1)
10-
pg (> 0, < 1000)
1110
sequel (> 0, < 1000)
1211

1312
GEM
@@ -125,6 +124,8 @@ GEM
125124
simplecov_json_formatter (~> 0.1)
126125
simplecov-html (0.13.2)
127126
simplecov_json_formatter (0.1.4)
127+
sqlite3 (2.9.6-arm64-darwin)
128+
sqlite3 (2.9.6-x86_64-linux-gnu)
128129
standard (1.54.0)
129130
language_server-protocol (~> 3.17.0.2)
130131
lint_roller (~> 1.0)
@@ -172,11 +173,13 @@ PLATFORMS
172173

173174
DEPENDENCIES
174175
debug
176+
pg
175177
riverqueue!
176178
riverqueue-sequel!
177179
rspec-core
178180
rspec-expectations
179181
simplecov
182+
sqlite3
180183
standard
181184
steep
182185

driver/riverqueue-activerecord/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ end
99

1010
group :test do
1111
gem "debug"
12+
gem "pg"
1213
gem "rspec-core"
1314
gem "rspec-expectations"
1415
gem "simplecov", require: false
16+
gem "sqlite3"
1517
end

driver/riverqueue-activerecord/Gemfile.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ PATH
99
riverqueue-activerecord (0.10.1)
1010
activerecord (> 0, < 1000)
1111
activesupport (> 0, < 1000)
12-
pg (> 0, < 1000)
1312

1413
GEM
1514
remote: https://rubygems.org/
@@ -115,6 +114,8 @@ GEM
115114
simplecov_json_formatter (~> 0.1)
116115
simplecov-html (0.13.2)
117116
simplecov_json_formatter (0.1.4)
117+
sqlite3 (2.9.3-arm64-darwin)
118+
sqlite3 (2.9.3-x86_64-linux-gnu)
118119
standard (1.54.0)
119120
language_server-protocol (~> 3.17.0.2)
120121
lint_roller (~> 1.0)
@@ -146,11 +147,13 @@ PLATFORMS
146147

147148
DEPENDENCIES
148149
debug
150+
pg
149151
riverqueue!
150152
riverqueue-activerecord!
151153
rspec-core
152154
rspec-expectations
153155
simplecov
156+
sqlite3
154157
standard
155158

156159
BUNDLED WITH
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# River Ruby bindings ActiveRecord driver
1+
# riverqueue-activerecord
22

3-
A future home for River's Ruby bindings. For now, the [Gem is registered](https://rubygems.org/gems/riverqueue), but nothing else is done.
4-
5-
``` sh
6-
$ gem build riverqueue-activerecord.gemspec
7-
$ gem push riverqueue-activerecord-0.0.1.gem
8-
```
3+
See the [ActiveRecord driver documentation](./docs/README.md).

driver/riverqueue-activerecord/docs/README.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
1-
# riverqueue-sequel [![Build Status](https://github.com/riverqueue/riverqueue-ruby-sequel/workflows/CI/badge.svg)](https://github.com/riverqueue/riverqueue-ruby-sequel/actions)
1+
# riverqueue-activerecord
22

3-
[ActiveRecord](https://github.com/jeremyevans/sequel) driver for [River](https://github.com/riverqueue/river)'s [`riverqueue` gem for Ruby](https://rubygems.org/gems/riverqueue).
3+
[ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html) driver for [River](https://github.com/riverqueue/river)'s [`riverqueue` gem for Ruby](https://rubygems.org/gems/riverqueue). PostgreSQL and SQLite are supported.
44

5-
`Gemfile` should contain the core gem and a driver like this one:
5+
Add the core gem and this driver to `Gemfile`:
66

7-
``` yaml
7+
```ruby
88
gem "riverqueue"
9-
gem "riverqueue-sequel"
9+
gem "riverqueue-activerecord"
10+
```
11+
12+
Database adapters are optional dependencies. Add only the adapter used by your
13+
application.
14+
15+
For PostgreSQL, add `pg` to `Gemfile`:
16+
17+
```ruby
18+
gem "pg"
19+
```
20+
21+
Then initialize a client with ActiveRecord's established connection:
22+
23+
```ruby
24+
ActiveRecord::Base.establish_connection("postgres://localhost/my_app")
25+
client = River::Client.new(River::Driver::ActiveRecord.new)
26+
```
27+
28+
For SQLite, add `sqlite3` to `Gemfile`:
29+
30+
```ruby
31+
gem "sqlite3"
1032
```
1133

12-
Initialize a client with:
34+
Then initialize a client with an SQLite connection:
1335

1436
```ruby
15-
DB = ActiveRecord.connect("postgres://...")
16-
client = River::Client.new(River::Driver::ActiveRecord.new(DB))
37+
ActiveRecord::Base.establish_connection(
38+
adapter: "sqlite3",
39+
database: "storage/river.sqlite3",
40+
timeout: 5_000
41+
)
42+
client = River::Client.new(River::Driver::ActiveRecord.new)
1743
```
1844

19-
See also [`rubyqueue`](https://github.com/riverqueue/riverqueue-ruby).
45+
Use current River migrations to create and update the SQLite database.
2046

2147
## Development
2248

0 commit comments

Comments
 (0)