logidze 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +3 -0
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +29 -0
- data/.rubocop.yml +30 -69
- data/.travis.yml +8 -5
- data/CHANGELOG.md +35 -1
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +67 -26
- data/Rakefile +2 -2
- data/assets/pg_log_data_chart.png +0 -0
- data/bench/performance/README.md +2 -2
- data/bench/performance/diff_bench.rb +15 -13
- data/bench/performance/insert_bench.rb +6 -4
- data/bench/performance/memory_profile.rb +12 -9
- data/bench/performance/setup.rb +35 -28
- data/bench/performance/update_bench.rb +8 -6
- data/bin/setup +2 -2
- data/gemfiles/rails42.gemfile +1 -0
- data/gemfiles/rails6.gemfile +6 -0
- data/lib/generators/logidze/install/install_generator.rb +3 -2
- data/lib/generators/logidze/model/model_generator.rb +12 -12
- data/lib/logidze.rb +44 -18
- data/lib/logidze/engine.rb +2 -1
- data/lib/logidze/has_logidze.rb +14 -4
- data/lib/logidze/history.rb +6 -5
- data/lib/logidze/history/type.rb +1 -1
- data/lib/logidze/history/version.rb +6 -5
- data/lib/logidze/ignore_log_data.rb +31 -4
- data/lib/logidze/ignore_log_data/association.rb +11 -0
- data/lib/logidze/ignore_log_data/default_scope_patch.rb +25 -0
- data/lib/logidze/ignore_log_data/ignored_columns.rb +1 -1
- data/lib/logidze/ignore_log_data/missing_attribute_patch.rb +3 -1
- data/lib/logidze/meta.rb +1 -1
- data/lib/logidze/migration.rb +1 -0
- data/lib/logidze/model.rb +14 -4
- data/lib/logidze/version.rb +2 -1
- data/lib/logidze/versioned_association.rb +0 -1
- data/logidze.gemspec +16 -8
- metadata +28 -60
- data/.hound.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56aa14f81cc160897376ed2b226664fc3a93c5f4becedb7d5a45abd197d03388
|
4
|
+
data.tar.gz: 5e196a2ef847e0e1d6069e793fb726f35166f05be007d9c4e4cfde2318b2cd3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8871956c3f1439fdd5cc3bb810e612a75145a49cf7f43a039b92915a2edc2ab57bb49a7bd5a4a14a48863696f37d8afcce4f052b2c620b01ffd5a179398fc30
|
7
|
+
data.tar.gz: 15440ace63434523644340155bd26bdb55acb906993b4b6014d1dd8d0f0e498d4e34709bc144bb3da260c8e509f336dc68c9100cc37568d3354d025a9d88cf39
|
data/.gitattributes
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
<!--
|
2
|
+
This template is for bug reports. If you are reporting a bug, please continue on. If you are here for another reason,
|
3
|
+
feel free to skip the rest of this template.
|
4
|
+
-->
|
5
|
+
|
6
|
+
### Tell us about your environment
|
7
|
+
|
8
|
+
**Ruby Version:**
|
9
|
+
|
10
|
+
**Rails Version:**
|
11
|
+
|
12
|
+
**PostgreSQL Version:**
|
13
|
+
|
14
|
+
**Logidze Version:**
|
15
|
+
|
16
|
+
### What did you do?
|
17
|
+
|
18
|
+
### What did you expect to happen?
|
19
|
+
|
20
|
+
### What actually happened?
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!--
|
2
|
+
First of all, thanks for contributing!
|
3
|
+
|
4
|
+
If it's a typo fix or minor documentation update feel free to skip the rest of this template!
|
5
|
+
-->
|
6
|
+
|
7
|
+
<!--
|
8
|
+
If it's a bug fix, then link it to the issue, for example:
|
9
|
+
|
10
|
+
Fixes #xxx
|
11
|
+
-->
|
12
|
+
|
13
|
+
|
14
|
+
<!--
|
15
|
+
Otherwise, describe the changes:
|
16
|
+
|
17
|
+
### What is the purpose of this pull request?
|
18
|
+
|
19
|
+
### What changes did you make? (overview)
|
20
|
+
|
21
|
+
### Is there anything you'd like reviewers to focus on?
|
22
|
+
|
23
|
+
### Checklist
|
24
|
+
|
25
|
+
- [ ] I've added tests for this change
|
26
|
+
- [ ] I've added a Changelog entry
|
27
|
+
- [ ] I've updated a documentation (Readme)
|
28
|
+
|
29
|
+
-->
|
data/.rubocop.yml
CHANGED
@@ -1,94 +1,55 @@
|
|
1
1
|
require:
|
2
|
+
- standard/cop/semantic_blocks
|
2
3
|
- rubocop-md
|
3
4
|
|
5
|
+
inherit_gem:
|
6
|
+
standard: config/base.yml
|
7
|
+
|
4
8
|
AllCops:
|
5
|
-
# Include gemspec and Rakefile
|
6
|
-
Include:
|
7
|
-
- 'lib/**/*.rb'
|
8
|
-
- 'lib/**/*.rake'
|
9
|
-
- 'spec/**/*.rb'
|
10
9
|
Exclude:
|
11
|
-
- 'bin
|
12
|
-
- 'spec/dummy/**/*'
|
13
|
-
- 'vendor/**/*'
|
14
|
-
- 'gemfiles/**/*'
|
10
|
+
- 'bin/*'
|
15
11
|
- 'tmp/**/*'
|
16
|
-
- '
|
17
|
-
- 'Rakefile'
|
12
|
+
- 'docs/**/*'
|
18
13
|
- 'Gemfile'
|
19
|
-
- '
|
14
|
+
- 'vendor/**/*'
|
15
|
+
- 'gemfiles/**/*'
|
20
16
|
DisplayCopNames: true
|
21
|
-
|
22
|
-
TargetRubyVersion: 2.3
|
23
|
-
|
24
|
-
Naming/AccessorMethodName:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Naming/UncommunicativeMethodParamName:
|
28
|
-
Enabled: false
|
17
|
+
TargetRubyVersion: 2.4
|
29
18
|
|
30
|
-
|
19
|
+
Standard/SemanticBlocks:
|
31
20
|
Enabled: false
|
32
21
|
|
33
|
-
Style/
|
34
|
-
|
35
|
-
- 'spec/**/*.rb'
|
36
|
-
|
37
|
-
Style/StringLiterals:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
Layout/SpaceInsideStringInterpolation:
|
41
|
-
EnforcedStyle: no_space
|
42
|
-
|
43
|
-
Style/BlockDelimiters:
|
44
|
-
Exclude:
|
45
|
-
- 'spec/**/*.rb'
|
22
|
+
Style/FrozenStringLiteralComment:
|
23
|
+
Enabled: true
|
46
24
|
|
47
|
-
Style/
|
48
|
-
|
25
|
+
Style/TrailingCommaInArrayLiteral:
|
26
|
+
EnforcedStyleForMultiline: no_comma
|
49
27
|
|
50
|
-
|
51
|
-
|
28
|
+
Style/TrailingCommaInHashLiteral:
|
29
|
+
EnforcedStyleForMultiline: no_comma
|
52
30
|
|
53
|
-
|
54
|
-
|
31
|
+
Layout/AlignParameters:
|
32
|
+
EnforcedStyle: with_first_parameter
|
55
33
|
|
56
|
-
Lint/
|
34
|
+
Lint/Void:
|
57
35
|
Exclude:
|
58
36
|
- '**/*.md'
|
59
37
|
|
60
|
-
|
38
|
+
# See https://github.com/rubocop-hq/rubocop/issues/4222
|
39
|
+
Lint/AmbiguousBlockAssociation:
|
61
40
|
Exclude:
|
62
|
-
- 'spec
|
41
|
+
- 'spec/**/*'
|
42
|
+
- '**/*.md'
|
63
43
|
|
64
|
-
|
44
|
+
Lint/DuplicateMethods:
|
65
45
|
Exclude:
|
66
|
-
- '
|
46
|
+
- '**/*.md'
|
67
47
|
|
68
|
-
|
69
|
-
Max: 100
|
48
|
+
Naming/FileName:
|
70
49
|
Exclude:
|
71
|
-
- '
|
72
|
-
|
73
|
-
Rails/Date:
|
74
|
-
Enabled: false
|
75
|
-
|
76
|
-
Rails/TimeZone:
|
77
|
-
Enabled: false
|
78
|
-
|
79
|
-
Style/NumericLiteralPrefix:
|
80
|
-
Enabled: false
|
50
|
+
- 'lib/test-prof.rb'
|
51
|
+
- '**/*.md'
|
81
52
|
|
82
|
-
|
83
|
-
Enabled: true
|
53
|
+
Layout/InitialIndentation:
|
84
54
|
Exclude:
|
85
|
-
- '
|
86
|
-
|
87
|
-
Layout/DotPosition:
|
88
|
-
EnforcedStyle: leading
|
89
|
-
|
90
|
-
Layout/IndentHeredoc:
|
91
|
-
Enabled: false
|
92
|
-
|
93
|
-
Layout/EmptyLineAfterMagicComment:
|
94
|
-
Enabled: false
|
55
|
+
- 'CHANGELOG.md'
|
data/.travis.yml
CHANGED
@@ -4,6 +4,9 @@ cache: bundler
|
|
4
4
|
dist: trusty
|
5
5
|
sudo: false
|
6
6
|
|
7
|
+
notifications:
|
8
|
+
email: false
|
9
|
+
|
7
10
|
addons:
|
8
11
|
postgresql: "9.6"
|
9
12
|
|
@@ -16,21 +19,21 @@ before_script:
|
|
16
19
|
- gem update --system
|
17
20
|
- bundle exec rake dummy:db:create
|
18
21
|
- psql -U postgres -d logidze -c 'CREATE EXTENSION IF NOT EXISTS hstore;'
|
19
|
-
- bundle exec rake dummy:db:
|
22
|
+
- RAILS_ENV=test bundle exec rake dummy:db:create dummy:db:migrate
|
20
23
|
|
21
24
|
matrix:
|
22
25
|
include:
|
23
26
|
- rvm: ruby-head
|
24
27
|
gemfile: gemfiles/railsmaster.gemfile
|
25
|
-
- rvm: 2.
|
26
|
-
gemfile: gemfiles/
|
27
|
-
- rvm: 2.
|
28
|
+
- rvm: 2.6.2
|
29
|
+
gemfile: gemfiles/rails6.gemfile
|
30
|
+
- rvm: 2.6.2
|
28
31
|
gemfile: gemfiles/rails5.gemfile
|
29
32
|
- rvm: 2.5.1
|
30
33
|
gemfile: gemfiles/rails52.gemfile
|
31
34
|
- rvm: 2.4.1
|
32
35
|
gemfile: gemfiles/rails5.gemfile
|
33
|
-
- rvm: 2.
|
36
|
+
- rvm: 2.4.1
|
34
37
|
gemfile: gemfiles/rails42.gemfile
|
35
38
|
allow_failures:
|
36
39
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,40 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
## master
|
3
|
+
## master (unreleased)
|
4
|
+
|
5
|
+
## 0.10.0 (2019-05-15)
|
6
|
+
|
7
|
+
- **Ruby >= 2.4 is required**
|
8
|
+
|
9
|
+
- PR [#111](https://github.com/palkan/logidze/pull/111) Global configuration for `:ignore_log_data` option ([@dmitrytsepelev][])
|
10
|
+
|
11
|
+
Now it's possible to avoid loading `log_data` from the DB by default with
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
Logidze.ignore_log_data_by_default = true
|
15
|
+
```
|
16
|
+
|
17
|
+
In cases when `ignore_log_data: false` is explicitly passed to the `ignore_log_data` the default setting is being overriden. Also, it's possible to change it inside the block:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
Logidze.with_log_data do
|
21
|
+
Post.find(params[:id]).log_data
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
- PR [#110](https://github.com/palkan/logidze/pull/110) Add `reset_log_data` API to nullify log_data column ([@Arkweid][])
|
26
|
+
|
27
|
+
Usage:
|
28
|
+
|
29
|
+
Reset the history for a record (or records):
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# for single record
|
33
|
+
record.reset_log_data
|
34
|
+
|
35
|
+
# for relation
|
36
|
+
User.where(active: true).reset_log_data
|
37
|
+
```
|
4
38
|
|
5
39
|
## 0.9.0 (2018-11-28)
|
6
40
|
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Currently, only PostgreSQL 9.5+ is supported (for PostgreSQL 9.4 try [jsonbx](ht
|
|
14
14
|
|
15
15
|
Other requirements:
|
16
16
|
- Ruby ~> 2.1
|
17
|
-
- Rails >= 4.2
|
17
|
+
- Rails >= 4.2 (**Rails 6 is supported**)
|
18
18
|
|
19
19
|
<a href="https://evilmartians.com/">
|
20
20
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
@@ -24,7 +24,7 @@ Other requirements:
|
|
24
24
|
Add Logidze to your application's Gemfile:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
gem
|
27
|
+
gem "logidze"
|
28
28
|
```
|
29
29
|
|
30
30
|
Install required DB extensions and create trigger function:
|
@@ -33,7 +33,7 @@ Install required DB extensions and create trigger function:
|
|
33
33
|
rails generate logidze:install
|
34
34
|
```
|
35
35
|
|
36
|
-
This creates migration for adding trigger function and enabling hstore extension.
|
36
|
+
This creates a migration for adding trigger function and enabling the hstore extension.
|
37
37
|
|
38
38
|
Run migrations:
|
39
39
|
|
@@ -57,13 +57,13 @@ rake db:migrate
|
|
57
57
|
|
58
58
|
This also adds `has_logidze` line to your model, which adds methods for working with logs.
|
59
59
|
|
60
|
-
You can provide `limit` option to `generate` to limit the size of the log (by default it's unlimited):
|
60
|
+
You can provide the `limit` option to `generate` to limit the size of the log (by default it's unlimited):
|
61
61
|
|
62
62
|
```sh
|
63
63
|
rails generate logidze:model Post --limit=10
|
64
64
|
```
|
65
65
|
|
66
|
-
To backfill table data (i.e
|
66
|
+
To backfill table data (i.e., create initial snapshots) add `backfill` option:
|
67
67
|
|
68
68
|
```sh
|
69
69
|
rails generate logidze:model Post --backfill
|
@@ -78,7 +78,7 @@ rails generate logidze:model Post --blacklist=created_at active
|
|
78
78
|
rails generate logidze:model Post --whitelist=title body
|
79
79
|
```
|
80
80
|
|
81
|
-
By default, Logidze tries to infer the path to the model file from the model name and may fail, for example, if you have unconventional project structure. In that case you should specify the path explicitly:
|
81
|
+
By default, Logidze tries to infer the path to the model file from the model name and may fail, for example, if you have unconventional project structure. In that case, you should specify the path explicitly:
|
82
82
|
|
83
83
|
```sh
|
84
84
|
rails generate logidze:model Post --path "app/models/custom/post.rb"
|
@@ -101,7 +101,7 @@ If you want to update Logidze settings for the model, run migration with `--upda
|
|
101
101
|
rails generate logidze:model Post --update --whitelist=title body rating
|
102
102
|
```
|
103
103
|
|
104
|
-
Logidze also supports associations versioning. It is experimental feature
|
104
|
+
Logidze also supports associations versioning. It is an experimental feature and disabled by default. You can learn more
|
105
105
|
in the [wiki](https://github.com/palkan/logidze/wiki/Associations-versioning).
|
106
106
|
|
107
107
|
## Troubleshooting
|
@@ -118,7 +118,7 @@ Nevertheless, you still need super-user privileges to enable `hstore` extension
|
|
118
118
|
|
119
119
|
## Upgrade from previous versions
|
120
120
|
|
121
|
-
We try to make upgrade process as simple as possible. For now, the only required action is to create and run a migration:
|
121
|
+
We try to make an upgrade process as simple as possible. For now, the only required action is to create and run a migration:
|
122
122
|
|
123
123
|
```sh
|
124
124
|
rails generate logidze:install --update
|
@@ -128,7 +128,7 @@ This updates core `logdize_logger` DB function. No need to update tables or trig
|
|
128
128
|
|
129
129
|
## Usage
|
130
130
|
|
131
|
-
Your model now has `log_data` column which stores changes log.
|
131
|
+
Your model now has `log_data` column, which stores changes log.
|
132
132
|
|
133
133
|
To retrieve record version at a given time use `#at` or `#at!` methods:
|
134
134
|
|
@@ -142,13 +142,13 @@ post.log_version #=> 3
|
|
142
142
|
post.log_size #=> 3
|
143
143
|
|
144
144
|
# Get copy of a record at a given time
|
145
|
-
|
145
|
+
post.at(time: 2.days.ago)
|
146
146
|
|
147
147
|
# or revert the record itself to the previous state (without committing to DB)
|
148
|
-
post.at!(time:
|
148
|
+
post.at!(time: "2018-04-15 12:00:00")
|
149
149
|
|
150
150
|
# If no version found
|
151
|
-
post.at(time:
|
151
|
+
post.at(time: "1945-05-09 09:00:00") #=> nil
|
152
152
|
```
|
153
153
|
|
154
154
|
You can also get revision by version number:
|
@@ -192,38 +192,68 @@ You can initiate reloading of `log_data` from the DB:
|
|
192
192
|
post.reload_log_data # => returns the latest log data value
|
193
193
|
```
|
194
194
|
|
195
|
-
|
195
|
+
Typically, if you update record after `#undo!` or `#switch_to!` you lose all "future" versions and `#redo!` is no
|
196
196
|
longer possible. However, you can provide an `append: true` option to `#undo!` or `#switch_to!`, which will
|
197
197
|
create a new version with old data. Caveat: when switching to a newer version, `append` will have no effect.
|
198
198
|
|
199
199
|
```ruby
|
200
|
-
post = Post.create!(title:
|
201
|
-
post.update!(title:
|
200
|
+
post = Post.create!(title: "first post") # v1
|
201
|
+
post.update!(title: "new title") # v2
|
202
202
|
post.undo!(append: true) # v3 (with same attributes as v1)
|
203
203
|
```
|
204
204
|
|
205
205
|
Note that `redo!` will not work after `undo!(append: true)` because the latter will create a new version
|
206
206
|
instead of rolling back to an old one.
|
207
|
-
Alternatively, you can configure Logidze to
|
207
|
+
Alternatively, you can configure Logidze always to default to `append: true`.
|
208
208
|
|
209
209
|
```ruby
|
210
210
|
Logidze.append_on_undo = true
|
211
211
|
```
|
212
212
|
|
213
|
-
|
213
|
+
### How to not load log data by default, or dealing with large logs
|
214
|
+
|
215
|
+
By default, Active Record _selects_ all the table columns when no explicit `select` statement specified.
|
216
|
+
|
217
|
+
That could slow down queries execution if you have field values which exceed the size of the data block (typically 8KB). PostgreSQL turns on its [TOAST](https://wiki.postgresql.org/wiki/TOAST) mechanism), which requires reading from multiple physical locations for fetching the row's data.
|
218
|
+
|
219
|
+
If you do not use compaction (`generate logidze:model ... --limit N`) for `log_data`, you're likely to face this problem.
|
220
|
+
|
221
|
+
Logidze provides a way to avoid loading `log_data` by default (and load it on demand):
|
214
222
|
|
215
223
|
```ruby
|
216
224
|
class User < ActiveRecord::Base
|
225
|
+
# Add `ignore_log_data` option to macros
|
217
226
|
has_logidze ignore_log_data: true
|
218
227
|
end
|
219
228
|
```
|
220
229
|
|
221
|
-
|
230
|
+
If you want Logidze always to behave this way - you can set up a global configuration option:
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
Rails.application.config.logidze.ignore_log_data_by_default = true
|
234
|
+
```
|
235
|
+
|
236
|
+
However, you can override it by explicitly passing `ignore_log_data: false` to the `ignore_log_data`. Also, it's possible to change it temporary inside the block:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
Logidze.with_log_data do
|
240
|
+
Post.find(params[:id]).log_data
|
241
|
+
end
|
242
|
+
```
|
222
243
|
|
244
|
+
When `ignore_log_data` is turned on, each time you use `User.all` (or any other Relation method) `log_data` won't be loaded from the DB.
|
245
|
+
|
246
|
+
The chart below shows the difference in PG query time before and after turning `ignore_log_data` on. (Special thanks to [@aderyabin](https://github.com/aderyabin) for sharing it.)
|
247
|
+
|
248
|
+
![](./assets/pg_log_data_chart.png)
|
249
|
+
|
250
|
+
If you try to call `#log_data` on the model loaded in such way, you'll get `ActiveModel::MissingAttributeError`, but if you really need it (e.g., during the console debugging) - use **`user.reload_log_data`**, which forces loading the column from the DB.
|
251
|
+
|
252
|
+
If you need to select `log_data` during the initial load-use a special scope `User.with_log_data`.
|
223
253
|
|
224
254
|
## Track meta information
|
225
255
|
|
226
|
-
You can store any meta information you want inside your version (it could be IP address, user agent etc).
|
256
|
+
You can store any meta information you want inside your version (it could be IP address, user agent, etc.). To add it you should wrap your code with a block:
|
227
257
|
|
228
258
|
```ruby
|
229
259
|
Logidze.with_meta(ip: request.ip) do
|
@@ -251,7 +281,7 @@ And then to retrieve `responsible_id`:
|
|
251
281
|
post.log_data.responsible_id
|
252
282
|
```
|
253
283
|
|
254
|
-
Logidze does not require `responsible_id` to be `SomeModel` ID. It can be anything. Thus Logidze does not provide methods for retrieving the corresponding object. However, you can
|
284
|
+
Logidze does not require `responsible_id` to be `SomeModel` ID. It can be anything. Thus Logidze does not provide methods for retrieving the corresponding object. However, you can easily write it yourself:
|
255
285
|
|
256
286
|
```ruby
|
257
287
|
class Post < ActiveRecord::Base
|
@@ -268,9 +298,9 @@ And in your controller:
|
|
268
298
|
|
269
299
|
```ruby
|
270
300
|
class ApplicationController < ActionController::Base
|
271
|
-
around_action :
|
301
|
+
around_action :use_logidze_responsible, only: %i[create update]
|
272
302
|
|
273
|
-
def
|
303
|
+
def use_logidze_responsible(&block)
|
274
304
|
Logidze.with_responsible(current_user&.id, &block)
|
275
305
|
end
|
276
306
|
end
|
@@ -278,7 +308,7 @@ end
|
|
278
308
|
|
279
309
|
## Disable logging temporary
|
280
310
|
|
281
|
-
If you want to make update without logging (e.g
|
311
|
+
If you want to make update without logging (e.g., mass update), you can turn it off the following way:
|
282
312
|
|
283
313
|
```ruby
|
284
314
|
Logidze.without_logging { Post.update_all(seen: true) }
|
@@ -288,6 +318,18 @@ Logidze.without_logging { Post.update_all(seen: true) }
|
|
288
318
|
Post.without_logging { Post.update_all(seen: true) }
|
289
319
|
```
|
290
320
|
|
321
|
+
## Reset log
|
322
|
+
|
323
|
+
Reset the history for a record (or records):
|
324
|
+
|
325
|
+
```ruby
|
326
|
+
# for a single record
|
327
|
+
record.reset_log_data
|
328
|
+
|
329
|
+
# for relation
|
330
|
+
User.where(active: true).reset_log_data
|
331
|
+
```
|
332
|
+
|
291
333
|
## Log format
|
292
334
|
|
293
335
|
The `log_data` column has the following format:
|
@@ -314,7 +356,7 @@ The `log_data` column has the following format:
|
|
314
356
|
}
|
315
357
|
```
|
316
358
|
|
317
|
-
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.
|
359
|
+
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.
|
318
360
|
|
319
361
|
## Development
|
320
362
|
|
@@ -324,8 +366,7 @@ For development setup run `./bin/setup`. This runs `bundle install` and creates
|
|
324
366
|
|
325
367
|
Bug reports and pull requests are welcome on GitHub at https://github.com/palkan/logidze.
|
326
368
|
|
327
|
-
|
328
|
-
## TODO
|
369
|
+
## Future ideas
|
329
370
|
|
330
371
|
- Enhance update_all to support mass-logging.
|
331
372
|
- Other DB adapters.
|