sequelize-rails 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +74 -73
- data/README.md +66 -33
- data/lib/sequel/rails/railtie.rb +2 -1
- data/lib/sequel/rails/version.rb +1 -1
- data/lib/sequel/rails.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1b95356822be96711195c7cb2756d2c84d3f1e8d1db2d9bdc1e4e7defee16d5
|
4
|
+
data.tar.gz: e1261347c5eb6b75c3e5fcd7407cea9d17cc3deb451c7c0847cbf0316863c6ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5152e52462ee0e45700ab0650a3ea61cff498c8bd8022769db5f712785e4d123db5910b6c19b9cd0ffd8a489af6dcd9f8b5ae8f50bfe3030e47e6cfe928576dd
|
7
|
+
data.tar.gz: 9ffb4fe02077f5b269ed43124da05e9e48db8fae102e4ea7f00b624d4dcc1566d7efa7f0d1d2f7e0e5f73e2d8a1a4b517375d01ec7a6740365f061ff60461bd3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.1
|
3
|
+
## [0.4.1] - 2023-08-16
|
4
4
|
|
5
|
-
-
|
5
|
+
- Adds a `Rails.application.config.sequel.after_connect` hook that is called after each connection is established. This hook can be used to add plugins and extensions to the database connection once established.
|
6
|
+
|
7
|
+
## [0.4.0] - 2023-08-16
|
8
|
+
|
9
|
+
- Rake tasks will no longer attempt a database connection by default
|
10
|
+
- A new `db:connection` rake task has been added for explicitly connecting to the primary database
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sequelize-rails (0.
|
4
|
+
sequelize-rails (0.4.1)
|
5
5
|
activerecord (>= 6.0.0)
|
6
6
|
rails (>= 6.0.0)
|
7
7
|
sequel (>= 5.0.0)
|
@@ -9,67 +9,67 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actioncable (7.0.
|
13
|
-
actionpack (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
12
|
+
actioncable (7.0.7)
|
13
|
+
actionpack (= 7.0.7)
|
14
|
+
activesupport (= 7.0.7)
|
15
15
|
nio4r (~> 2.0)
|
16
16
|
websocket-driver (>= 0.6.1)
|
17
|
-
actionmailbox (7.0.
|
18
|
-
actionpack (= 7.0.
|
19
|
-
activejob (= 7.0.
|
20
|
-
activerecord (= 7.0.
|
21
|
-
activestorage (= 7.0.
|
22
|
-
activesupport (= 7.0.
|
17
|
+
actionmailbox (7.0.7)
|
18
|
+
actionpack (= 7.0.7)
|
19
|
+
activejob (= 7.0.7)
|
20
|
+
activerecord (= 7.0.7)
|
21
|
+
activestorage (= 7.0.7)
|
22
|
+
activesupport (= 7.0.7)
|
23
23
|
mail (>= 2.7.1)
|
24
24
|
net-imap
|
25
25
|
net-pop
|
26
26
|
net-smtp
|
27
|
-
actionmailer (7.0.
|
28
|
-
actionpack (= 7.0.
|
29
|
-
actionview (= 7.0.
|
30
|
-
activejob (= 7.0.
|
31
|
-
activesupport (= 7.0.
|
27
|
+
actionmailer (7.0.7)
|
28
|
+
actionpack (= 7.0.7)
|
29
|
+
actionview (= 7.0.7)
|
30
|
+
activejob (= 7.0.7)
|
31
|
+
activesupport (= 7.0.7)
|
32
32
|
mail (~> 2.5, >= 2.5.4)
|
33
33
|
net-imap
|
34
34
|
net-pop
|
35
35
|
net-smtp
|
36
36
|
rails-dom-testing (~> 2.0)
|
37
|
-
actionpack (7.0.
|
38
|
-
actionview (= 7.0.
|
39
|
-
activesupport (= 7.0.
|
40
|
-
rack (~> 2.0, >= 2.2.
|
37
|
+
actionpack (7.0.7)
|
38
|
+
actionview (= 7.0.7)
|
39
|
+
activesupport (= 7.0.7)
|
40
|
+
rack (~> 2.0, >= 2.2.4)
|
41
41
|
rack-test (>= 0.6.3)
|
42
42
|
rails-dom-testing (~> 2.0)
|
43
43
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
44
|
-
actiontext (7.0.
|
45
|
-
actionpack (= 7.0.
|
46
|
-
activerecord (= 7.0.
|
47
|
-
activestorage (= 7.0.
|
48
|
-
activesupport (= 7.0.
|
44
|
+
actiontext (7.0.7)
|
45
|
+
actionpack (= 7.0.7)
|
46
|
+
activerecord (= 7.0.7)
|
47
|
+
activestorage (= 7.0.7)
|
48
|
+
activesupport (= 7.0.7)
|
49
49
|
globalid (>= 0.6.0)
|
50
50
|
nokogiri (>= 1.8.5)
|
51
|
-
actionview (7.0.
|
52
|
-
activesupport (= 7.0.
|
51
|
+
actionview (7.0.7)
|
52
|
+
activesupport (= 7.0.7)
|
53
53
|
builder (~> 3.1)
|
54
54
|
erubi (~> 1.4)
|
55
55
|
rails-dom-testing (~> 2.0)
|
56
56
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
57
|
-
activejob (7.0.
|
58
|
-
activesupport (= 7.0.
|
57
|
+
activejob (7.0.7)
|
58
|
+
activesupport (= 7.0.7)
|
59
59
|
globalid (>= 0.3.6)
|
60
|
-
activemodel (7.0.
|
61
|
-
activesupport (= 7.0.
|
62
|
-
activerecord (7.0.
|
63
|
-
activemodel (= 7.0.
|
64
|
-
activesupport (= 7.0.
|
65
|
-
activestorage (7.0.
|
66
|
-
actionpack (= 7.0.
|
67
|
-
activejob (= 7.0.
|
68
|
-
activerecord (= 7.0.
|
69
|
-
activesupport (= 7.0.
|
60
|
+
activemodel (7.0.7)
|
61
|
+
activesupport (= 7.0.7)
|
62
|
+
activerecord (7.0.7)
|
63
|
+
activemodel (= 7.0.7)
|
64
|
+
activesupport (= 7.0.7)
|
65
|
+
activestorage (7.0.7)
|
66
|
+
actionpack (= 7.0.7)
|
67
|
+
activejob (= 7.0.7)
|
68
|
+
activerecord (= 7.0.7)
|
69
|
+
activesupport (= 7.0.7)
|
70
70
|
marcel (~> 1.0)
|
71
71
|
mini_mime (>= 1.1.0)
|
72
|
-
activesupport (7.0.
|
72
|
+
activesupport (7.0.7)
|
73
73
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
74
74
|
i18n (>= 1.6, < 2)
|
75
75
|
minitest (>= 5.1)
|
@@ -88,13 +88,13 @@ GEM
|
|
88
88
|
erubi (1.12.0)
|
89
89
|
globalid (1.1.0)
|
90
90
|
activesupport (>= 5.0)
|
91
|
-
i18n (1.
|
91
|
+
i18n (1.14.1)
|
92
92
|
concurrent-ruby (~> 1.0)
|
93
93
|
json (2.6.3)
|
94
94
|
language_server-protocol (3.17.0.3)
|
95
|
-
loofah (2.
|
95
|
+
loofah (2.21.3)
|
96
96
|
crass (~> 1.0.2)
|
97
|
-
nokogiri (>= 1.
|
97
|
+
nokogiri (>= 1.12.0)
|
98
98
|
mail (2.8.1)
|
99
99
|
mini_mime (>= 0.1.1)
|
100
100
|
net-imap
|
@@ -102,7 +102,7 @@ GEM
|
|
102
102
|
net-smtp
|
103
103
|
marcel (1.0.2)
|
104
104
|
method_source (1.0.0)
|
105
|
-
mini_mime (1.1.
|
105
|
+
mini_mime (1.1.5)
|
106
106
|
mini_portile2 (2.8.1)
|
107
107
|
minitest (5.18.0)
|
108
108
|
minitest-reporters (1.6.0)
|
@@ -110,7 +110,7 @@ GEM
|
|
110
110
|
builder
|
111
111
|
minitest (>= 5.0)
|
112
112
|
ruby-progressbar
|
113
|
-
net-imap (0.3.
|
113
|
+
net-imap (0.3.7)
|
114
114
|
date
|
115
115
|
net-protocol
|
116
116
|
net-pop (0.1.2)
|
@@ -119,9 +119,8 @@ GEM
|
|
119
119
|
timeout
|
120
120
|
net-smtp (0.3.3)
|
121
121
|
net-protocol
|
122
|
-
nio4r (2.5.
|
123
|
-
nokogiri (1.
|
124
|
-
mini_portile2 (~> 2.8.0)
|
122
|
+
nio4r (2.5.9)
|
123
|
+
nokogiri (1.15.4-arm64-darwin)
|
125
124
|
racc (~> 1.4)
|
126
125
|
parallel (1.22.1)
|
127
126
|
parser (3.2.1.1)
|
@@ -130,32 +129,34 @@ GEM
|
|
130
129
|
pry (0.14.2)
|
131
130
|
coderay (~> 1.1)
|
132
131
|
method_source (~> 1.0)
|
133
|
-
racc (1.
|
134
|
-
rack (2.2.
|
132
|
+
racc (1.7.1)
|
133
|
+
rack (2.2.8)
|
135
134
|
rack-test (2.1.0)
|
136
135
|
rack (>= 1.3)
|
137
|
-
rails (7.0.
|
138
|
-
actioncable (= 7.0.
|
139
|
-
actionmailbox (= 7.0.
|
140
|
-
actionmailer (= 7.0.
|
141
|
-
actionpack (= 7.0.
|
142
|
-
actiontext (= 7.0.
|
143
|
-
actionview (= 7.0.
|
144
|
-
activejob (= 7.0.
|
145
|
-
activemodel (= 7.0.
|
146
|
-
activerecord (= 7.0.
|
147
|
-
activestorage (= 7.0.
|
148
|
-
activesupport (= 7.0.
|
136
|
+
rails (7.0.7)
|
137
|
+
actioncable (= 7.0.7)
|
138
|
+
actionmailbox (= 7.0.7)
|
139
|
+
actionmailer (= 7.0.7)
|
140
|
+
actionpack (= 7.0.7)
|
141
|
+
actiontext (= 7.0.7)
|
142
|
+
actionview (= 7.0.7)
|
143
|
+
activejob (= 7.0.7)
|
144
|
+
activemodel (= 7.0.7)
|
145
|
+
activerecord (= 7.0.7)
|
146
|
+
activestorage (= 7.0.7)
|
147
|
+
activesupport (= 7.0.7)
|
149
148
|
bundler (>= 1.15.0)
|
150
|
-
railties (= 7.0.
|
151
|
-
rails-dom-testing (2.0
|
152
|
-
activesupport (>=
|
149
|
+
railties (= 7.0.7)
|
150
|
+
rails-dom-testing (2.2.0)
|
151
|
+
activesupport (>= 5.0.0)
|
152
|
+
minitest
|
153
153
|
nokogiri (>= 1.6)
|
154
|
-
rails-html-sanitizer (1.
|
155
|
-
loofah (~> 2.
|
156
|
-
|
157
|
-
|
158
|
-
|
154
|
+
rails-html-sanitizer (1.6.0)
|
155
|
+
loofah (~> 2.21)
|
156
|
+
nokogiri (~> 1.14)
|
157
|
+
railties (7.0.7)
|
158
|
+
actionpack (= 7.0.7)
|
159
|
+
activesupport (= 7.0.7)
|
159
160
|
method_source
|
160
161
|
rake (>= 12.2)
|
161
162
|
thor (~> 1.0)
|
@@ -180,7 +181,7 @@ GEM
|
|
180
181
|
rubocop (>= 1.7.0, < 2.0)
|
181
182
|
rubocop-ast (>= 0.4.0)
|
182
183
|
ruby-progressbar (1.13.0)
|
183
|
-
sequel (5.
|
184
|
+
sequel (5.71.0)
|
184
185
|
sqlite3 (1.6.1)
|
185
186
|
mini_portile2 (~> 2.8.0)
|
186
187
|
standard (1.25.3)
|
@@ -188,14 +189,14 @@ GEM
|
|
188
189
|
rubocop (~> 1.48.1)
|
189
190
|
rubocop-performance (~> 1.16.0)
|
190
191
|
thor (1.2.1)
|
191
|
-
timeout (0.
|
192
|
+
timeout (0.4.0)
|
192
193
|
tzinfo (2.0.6)
|
193
194
|
concurrent-ruby (~> 1.0)
|
194
195
|
unicode-display_width (2.4.2)
|
195
|
-
websocket-driver (0.7.
|
196
|
+
websocket-driver (0.7.6)
|
196
197
|
websocket-extensions (>= 0.1.0)
|
197
198
|
websocket-extensions (0.1.5)
|
198
|
-
zeitwerk (2.6.
|
199
|
+
zeitwerk (2.6.11)
|
199
200
|
|
200
201
|
PLATFORMS
|
201
202
|
ruby
|
data/README.md
CHANGED
@@ -18,20 +18,26 @@ And then execute:
|
|
18
18
|
|
19
19
|
$ bundle install
|
20
20
|
|
21
|
-
If you are looking to replace ActiveRecord entirely, you may need to either generate your Rails app using `--skip-active-record` or manually remove references to ActiveRecord in your `Gemfile`,
|
21
|
+
If you are looking to replace ActiveRecord entirely, you may need to either generate your Rails app using `--skip-active-record` or manually remove references to ActiveRecord in your `Gemfile`, `config/application.rb`, and `config/environments/*.rb` files.
|
22
22
|
|
23
23
|
## Features provided by `sequelize-rails`
|
24
24
|
|
25
25
|
**Database Management**
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
- [x] [Connectivity](#---database-connectivity) via `config/database.yml`
|
28
|
+
- [x] [Console](#---database-console) via `rails db`
|
29
|
+
- [x] [Migrations](#---database-migrations) via `Sequel::Migration`
|
30
|
+
- [ ] [Migration Generators](#---migration-generators) via `rails generate migration` (not supported yet)
|
31
|
+
- [x] [Rake tasks](#---database-rake-tasks) via `rails db:*`
|
32
32
|
|
33
33
|
**Test Suite**
|
34
|
-
|
34
|
+
|
35
|
+
- [x] [Minitest Helpers](#---minitest-helpers)
|
36
|
+
|
37
|
+
**Rake Helpers**
|
38
|
+
|
39
|
+
- [x] Does not connect to the primary database in Rake (tasks by default)
|
40
|
+
- [x] Allows for explicit connection to the primary database by invoking `db:connection`
|
35
41
|
|
36
42
|
## ✅ - Database Connectivity
|
37
43
|
|
@@ -75,11 +81,37 @@ my_replica:
|
|
75
81
|
|
76
82
|
Additional connections can be retrieved via `Sequel::Rails.connect_to`, such as within the example below:
|
77
83
|
|
78
|
-
|
79
84
|
```ruby
|
80
85
|
replica_connection = Sequel::Rails.connect_to :my_replica
|
81
86
|
```
|
82
87
|
|
88
|
+
### Database Connections in Rake Tasks
|
89
|
+
|
90
|
+
By default, this gem will not connect to the primary database when running Rake tasks. This is to prevent Rake tasks from accidentally depending on a database connection when one is not necessary. If you would like to connect to the primary database within a Rake task, you can do so by invoking the `db:connection` task, or by calling `Sequel::Rails.connect_to :primary` from within your task.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
# Rakefile
|
94
|
+
|
95
|
+
# no database connections are initialized by default
|
96
|
+
task :no_db_connection do
|
97
|
+
Sequel::DATABASES # => []
|
98
|
+
Sequel::DATABASES.length # => 0
|
99
|
+
end
|
100
|
+
|
101
|
+
# connects to the primary database explicitly
|
102
|
+
task :my_task do
|
103
|
+
db = Sequel::Rails.connect_to :primary
|
104
|
+
Sequel::DATABASES # => [db]
|
105
|
+
Sequel::DATABASES.length # => 1
|
106
|
+
end
|
107
|
+
|
108
|
+
# connects to the primary database via the db:connection task
|
109
|
+
task :my_other_task => "db:connection" do
|
110
|
+
Sequel::DATABASES # => [<primary db connection here>]
|
111
|
+
Sequel::DATABASES.length # => 1
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
83
115
|
## ✅ - Database Console
|
84
116
|
|
85
117
|
You can connect directly to your database via the `rails db` command. This command is similar to the `rails console` command, but instead of loading your application, it will connect directly to the database.
|
@@ -108,19 +140,20 @@ Rails supports the generation of migrations via the `rails generate migration` c
|
|
108
140
|
|
109
141
|
This gem provides a set of rake tasks that are similar to the ActiveRecord tasks. These tasks can be used to create, drop, migrate, and seed your database.
|
110
142
|
|
111
|
-
| Task
|
112
|
-
|
|
113
|
-
| `rails db:create`
|
114
|
-
| `rails db:drop`
|
115
|
-
| `rails db:migrate`
|
116
|
-
| `rails db:migrate:redo`
|
117
|
-
| `rails db:migrate:status` | Displays the status of the database migrations
|
118
|
-
| `rails db:prepare`
|
119
|
-
| `rails db:reset`
|
120
|
-
| `rails db:rollback`
|
121
|
-
| `rails db:setup`
|
143
|
+
| Task | Description |
|
144
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
145
|
+
| `rails db:create` | Creates the database from `DATABASE_URL` or `config/database.yml` for the current `RAILS_ENV` (use `db:create:all` to create all databases in the config). |
|
146
|
+
| `rails db:drop` | Drops the database from `DATABASE_URL` or `config/database.yml` for the current `RAILS_ENV` (use `db:drop:all` to drop all databases in the config). |
|
147
|
+
| `rails db:migrate` | Runs database migrations |
|
148
|
+
| `rails db:migrate:redo` | Rolls back the last migration and re-runs it |
|
149
|
+
| `rails db:migrate:status` | Displays the status of the database migrations |
|
150
|
+
| `rails db:prepare` | Runs `db:setup` if the database does not exist or `db:migrate` if it does |
|
151
|
+
| `rails db:reset` | Runs `db:drop`, `db:setup` |
|
152
|
+
| `rails db:rollback` | Rolls back the last migration |
|
153
|
+
| `rails db:setup` | Runs the `db:create`, `db:migrate`, `db:seed` tasks |
|
122
154
|
|
123
155
|
## ✅ - Minitest Helpers
|
156
|
+
|
124
157
|
### `assert_num_queries`
|
125
158
|
|
126
159
|
This helper can be used to assert that a specific number of database queries are executed within the given block of code.
|
@@ -174,12 +207,12 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/kenani
|
|
174
207
|
|
175
208
|
This repository contains a handful of commands that can be used to facilitate this gem's development. These are:
|
176
209
|
|
177
|
-
| Command
|
178
|
-
|
|
179
|
-
| `bin/setup`
|
180
|
-
| `bin/test`
|
181
|
-
| `bin/console`
|
182
|
-
| `bundle exec rake release` | Creates a new release of the gem (version number should be bumped first)
|
210
|
+
| Command | Description |
|
211
|
+
| -------------------------- | ---------------------------------------------------------------------------------------- |
|
212
|
+
| `bin/setup` | Installs the gem's development dependencies |
|
213
|
+
| `bin/test` | Runs the test suite for each supported Rails version |
|
214
|
+
| `bin/console` | Starts an interactive console within the gem's test Rails app (located in `test/dummy/`) |
|
215
|
+
| `bundle exec rake release` | Creates a new release of the gem (version number should be bumped first) |
|
183
216
|
|
184
217
|
# License
|
185
218
|
|
@@ -187,11 +220,11 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
187
220
|
|
188
221
|
# Roadmap
|
189
222
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
223
|
+
- [ ] Support `rails console --sandbox` (auto rollback all transactions)
|
224
|
+
- [ ] Support logging
|
225
|
+
- [ ] Support db rake tasks
|
226
|
+
- [ ] Support reloading (disconnect all connections)
|
227
|
+
- [ ] Support ActiveRecord plugins / conventions (shims)
|
228
|
+
- [ ] Support PostgreSQL custom format for dump & restore
|
229
|
+
- [ ] Support generators (including orm)
|
230
|
+
- [ ] Support migration generator (and parsed attributes)
|
data/lib/sequel/rails/railtie.rb
CHANGED
@@ -51,7 +51,8 @@ module Sequel
|
|
51
51
|
end
|
52
52
|
|
53
53
|
initializer "sequel.connection" do
|
54
|
-
|
54
|
+
in_rake = Rails.const_defined?(:Rake) && Rake.application.top_level_tasks.length > 0
|
55
|
+
::Sequel::Rails.connect_to :primary unless in_rake
|
55
56
|
end
|
56
57
|
|
57
58
|
# Expose database runtime to controller for logging.
|
data/lib/sequel/rails/version.rb
CHANGED
data/lib/sequel/rails.rb
CHANGED
@@ -32,6 +32,9 @@ module Sequel
|
|
32
32
|
config[:pool_timeout] ||= config.delete(:timeout) / 1000 if config[:timeout]
|
33
33
|
Dir.chdir ::Rails.root do
|
34
34
|
::Sequel.connect config, opts
|
35
|
+
end.tap do |db|
|
36
|
+
callback = ::Rails.application.config.sequel.after_connect
|
37
|
+
callback.call(db) if callback.respond_to?(:call)
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequelize-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenaniah Cerny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|