waldit 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/waldit/migration.rb +3 -3
- data/lib/waldit/record.rb +10 -3
- data/lib/waldit/version.rb +1 -1
- data/lib/waldit/watcher.rb +1 -1
- data/rbi/waldit.rbi +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: b0c671c6e356548b94a0848e8f17e79634e8239113c685995305258c355388ef
|
4
|
+
data.tar.gz: d3bcc95f82f3230c5a8b50ec7917a74466166685a9685a8715769246e39bda71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a0b50f5ee3d46ddf7bdfe11242d7ac29e1fff2826c0ca63195401a377e39f1066d664c0b268d34a696c2568884b8adada0ed0a99c85cf039be1a018b1ce4a9
|
7
|
+
data.tar.gz: 87a8ce52ffe1f414d6c529f552bf9deecdbe303fe98be9639cd23944929f6b8770484b25560fcd4a9b76ea78eb31fd92f669478f2c00f9f57e4073251e315917
|
data/lib/waldit/migration.rb
CHANGED
@@ -14,7 +14,7 @@ module Waldit
|
|
14
14
|
t.string :primary_key, null: false
|
15
15
|
t.bigint :transaction_id, null: false
|
16
16
|
t.decimal :lsn, null: false, precision: 20, scale: 0
|
17
|
-
t.timestamptz :
|
17
|
+
t.timestamptz :committed_at
|
18
18
|
t.jsonb :context, null: false, default: {}
|
19
19
|
t.jsonb :old, null: true
|
20
20
|
t.jsonb :new, null: true
|
@@ -24,8 +24,8 @@ module Waldit
|
|
24
24
|
|
25
25
|
add_index name, [:table_name, :primary_key, :transaction_id], unique: true
|
26
26
|
add_index name, [:transaction_id, :lsn]
|
27
|
-
add_index name, [:action, :table_name, :
|
28
|
-
add_index name, :
|
27
|
+
add_index name, [:action, :table_name, :committed_at]
|
28
|
+
add_index name, :committed_at
|
29
29
|
add_index name, :context, using: :gin, opclass: :jsonb_path_ops
|
30
30
|
end
|
31
31
|
|
data/lib/waldit/record.rb
CHANGED
@@ -2,21 +2,28 @@
|
|
2
2
|
|
3
3
|
module Waldit
|
4
4
|
module Record
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
default_scope { order(:committed_at) }
|
8
|
+
scope :from_table, -> table { where(table_name: table) }
|
9
|
+
scope :from_model, -> model { from_table(model.table_name) }
|
10
|
+
scope :for, -> record { from_model(record.class).where(primary_key: record.id) }
|
11
|
+
scope :with_context, -> ctx { where("context @> ?", ctx.to_json) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
def new
|
6
16
|
return self[:new] if self[:new]
|
7
|
-
|
8
17
|
(self[:diff] || {}).transform_values { |_old, new| new }
|
9
18
|
end
|
10
19
|
|
11
20
|
def old
|
12
21
|
return self[:old] if self[:old]
|
13
|
-
|
14
22
|
(self[:diff] || {}).transform_values { |old, _new| old }
|
15
23
|
end
|
16
24
|
|
17
25
|
def diff
|
18
26
|
return self[:diff] if self[:diff]
|
19
|
-
|
20
27
|
(old.keys | new.keys).reduce({}) do |diff, key|
|
21
28
|
old[key] != new[key] ? diff.merge(key => [old[key], new[key]]) : diff
|
22
29
|
end
|
data/lib/waldit/version.rb
CHANGED
data/lib/waldit/watcher.rb
CHANGED
@@ -46,7 +46,7 @@ module Waldit
|
|
46
46
|
events.each do |event|
|
47
47
|
case event
|
48
48
|
when CommitTransactionEvent
|
49
|
-
record.where(transaction_id: event.transaction_id).update_all(
|
49
|
+
record.where(transaction_id: event.transaction_id).update_all(committed_at: event.timestamp)
|
50
50
|
|
51
51
|
changes = [:old, :new, :diff]
|
52
52
|
.map { |diff| [diff, tables.filter { |table| Waldit.store_changes.call(table).include? diff }] }
|
data/rbi/waldit.rbi
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waldit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Navarro
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-09-01 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: wal
|