sequelize-rails 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -2
- data/README.md +66 -33
- data/lib/sequel/rails/railtie.rb +2 -1
- data/lib/sequel/rails/version.rb +1 -1
- 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: 1d9b36457ef8b9c1cfc36554adb7b76a2c6262ac93fc9e6468a0c5e4eae74a04
|
4
|
+
data.tar.gz: 46a4e132f2d67a1c2aab16dcf1ec7fa39bb113f1dab39dbf2bb9a0e272af33da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d4ff60a438337fe2d9f9f440a74da942b8c9aad250c8a127500cab2ef6082dd5de45c15163abaa8f25e1ce26c7c6ad772fb24edf57995ac4c6c29191512bf4c
|
7
|
+
data.tar.gz: '08f935a29a8f038fc824d407cb8d988f0d1c0745f9465e01dbbfe870c9a4c97f021a251b3750a7b4b74e91865846d4a51121039d6aac2c2a10ddce312e72a697'
|
data/CHANGELOG.md
CHANGED
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
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.0
|
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
|