waldit 0.0.14 → 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 +8 -8
- data/lib/waldit/version.rb +1 -1
- data/lib/waldit/watcher.rb +1 -1
- data/rbi/waldit.rbi +1 -1
- metadata +1 -1
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,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module Waldit
|
4
4
|
module Record
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
13
|
end
|
14
14
|
|
15
15
|
def new
|
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