logidze 1.3.0 → 1.3.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 +13 -2
- data/README.md +16 -6
- data/lib/generators/logidze/model/model_generator.rb +6 -1
- data/lib/logidze/engine.rb +13 -0
- data/lib/logidze/version.rb +1 -1
- data/lib/logidze.rb +3 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c8113ee63d992fde09019059c1cbd3a6d75ab8914ad365106e954a66c28b633
|
4
|
+
data.tar.gz: e784d849dc188763ada793df28ad134226b2aa21416bbd818ac7e8c496ff1e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d427303c2f7f07f3f0d6964469d124d54dfac17615c881192115a426e9cafe517ad95850753bb6b0676211ffb33b4ed850aa11475ca6753b19c99f07a31421d4
|
7
|
+
data.tar.gz: 837353c8432d3a7c8e43f94949ad3ac45a0ca069d074d2db0e9acdad9abaabd03f04a5a0d9c3427f3ab710abd967a03d92f7eda02b6e15ce2c05fdb2b4e2b9fb
|
data/CHANGELOG.md
CHANGED
@@ -2,13 +2,23 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 1.3.1 (2024-10-23)
|
6
|
+
|
7
|
+
- Fix `rails destroy logidze:model SomeModel` not deleting the `fx` trigger file file. ([@tylerhunt][])
|
8
|
+
|
9
|
+
- Support sorting of trigger names alphabetically (defaults to false)
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Logdize.sort_triggers_by_name = true
|
13
|
+
```
|
14
|
+
|
5
15
|
## 1.3.0 (2024-01-09)
|
6
16
|
|
7
17
|
- Add retrieving list of versions support. ([@tagirahmad][])
|
8
18
|
|
9
19
|
```ruby
|
10
|
-
post.
|
11
|
-
post.
|
20
|
+
post.logidze_versions # => Enumerator
|
21
|
+
post.logidze_versions.find do
|
12
22
|
_1.title == "old title"
|
13
23
|
end
|
14
24
|
```
|
@@ -395,3 +405,4 @@ This is a quick fix for a more general problem (see [#59](https://github.com/pal
|
|
395
405
|
[@prog-supdex]: https://github.com/prog-supdex
|
396
406
|
[@SparLaimor]: https://github.com/SparLaimor
|
397
407
|
[@tagirahmad]: https://github.com/tagirahmad
|
408
|
+
[@tylerhunt]: https://github.com/tylerhunt
|
data/README.md
CHANGED
@@ -260,20 +260,20 @@ Post.where(created_at: Time.zone.today.all_day).diff_from(time: 1.hour.ago)
|
|
260
260
|
Also, it is possible to retrieve list of model's `versions`:
|
261
261
|
|
262
262
|
```ruby
|
263
|
-
post.
|
263
|
+
post.logidze_versions # => Enumerator
|
264
264
|
|
265
265
|
# you can use Enumerator's #take to return all
|
266
|
-
post.
|
266
|
+
post.logidze_versions.take
|
267
267
|
|
268
268
|
# or you take a few or call any Enumerable method
|
269
|
-
post.
|
270
|
-
post.
|
269
|
+
post.logidze_versions.take(2)
|
270
|
+
post.logidze_versions.find do
|
271
271
|
_1.title == "old title"
|
272
272
|
end
|
273
273
|
|
274
274
|
# we can also add options
|
275
|
-
post.
|
276
|
-
post.
|
275
|
+
post.logidze_versions(reverse: true) # from newer to older
|
276
|
+
post.logidze_versions(include_self: true) # returns self as the last record or the first one when `reverse` is set to true
|
277
277
|
```
|
278
278
|
|
279
279
|
There are also `#undo!` and `#redo!` options (and more general `#switch_to!`):
|
@@ -573,6 +573,16 @@ The `log_data` column has the following format:
|
|
573
573
|
|
574
574
|
If you specify the limit in the trigger definition, then log size will not exceed the specified size. When a new change occurs, and there is no more room for it, the two oldest changes will be merged.
|
575
575
|
|
576
|
+
## Ordering of Triggers in schema.rb
|
577
|
+
|
578
|
+
By default, when generating `schema.rb`, Rails will order the triggers based on the id's of their respective tables. This can lead to unnecessary changes being made when utilizing `rails db:prepare`, since the ordering of the tables will now be based off the alphabetical ordering (see [#250](https://github.com/palkan/logidze/issues/250) for more details). To force the ordering to be consistent with `rails db:prepare`, Logidze can be configured to order the triggers alphabetically.
|
579
|
+
|
580
|
+
```ruby
|
581
|
+
# config/initializers/logidze.rb
|
582
|
+
|
583
|
+
Logidze.sort_triggers_by_name = true
|
584
|
+
```
|
585
|
+
|
576
586
|
## Troubleshooting
|
577
587
|
|
578
588
|
### `log_data` is nil when using Rails fixtures
|
data/lib/logidze/engine.rb
CHANGED
@@ -20,5 +20,18 @@ module Logidze
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
initializer "sort triggers by name" do |app|
|
25
|
+
if config.logidze.sort_triggers_by_name
|
26
|
+
ActiveSupport.on_load(:active_record) do
|
27
|
+
require "fx/adapters/postgres/triggers"
|
28
|
+
Fx::Adapters::Postgres::Triggers.singleton_class.prepend(Module.new do
|
29
|
+
def all(*args)
|
30
|
+
super.sort_by(&:name)
|
31
|
+
end
|
32
|
+
end)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
23
36
|
end
|
24
37
|
end
|
data/lib/logidze/version.rb
CHANGED
data/lib/logidze.rb
CHANGED
@@ -25,6 +25,8 @@ module Logidze
|
|
25
25
|
attr_accessor :ignore_log_data_by_default
|
26
26
|
# Whether #at should return self or nil when log_data is nil
|
27
27
|
attr_accessor :return_self_if_log_data_is_empty
|
28
|
+
# Determines if triggers are sorted by related table id or by name
|
29
|
+
attr_accessor :sort_triggers_by_name
|
28
30
|
# Determines what Logidze should do when upgrade is needed (:raise | :warn | :ignore)
|
29
31
|
attr_reader :on_pending_upgrade
|
30
32
|
|
@@ -68,4 +70,5 @@ module Logidze
|
|
68
70
|
self.ignore_log_data_by_default = false
|
69
71
|
self.return_self_if_log_data_is_empty = true
|
70
72
|
self.on_pending_upgrade = :ignore
|
73
|
+
self.sort_triggers_by_name = false
|
71
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logidze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -188,7 +188,7 @@ metadata:
|
|
188
188
|
documentation_uri: http://github.com/palkan/logidze
|
189
189
|
homepage_uri: http://github.com/palkan/logidze
|
190
190
|
source_code_uri: http://github.com/palkan/logidze
|
191
|
-
post_install_message:
|
191
|
+
post_install_message:
|
192
192
|
rdoc_options: []
|
193
193
|
require_paths:
|
194
194
|
- lib
|
@@ -203,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
rubygems_version: 3.4.
|
207
|
-
signing_key:
|
206
|
+
rubygems_version: 3.4.19
|
207
|
+
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: PostgreSQL JSONB-based model changes tracking
|
210
210
|
test_files: []
|