waldit 0.0.9 → 0.0.11
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 +6 -6
- data/lib/waldit/version.rb +1 -1
- data/lib/waldit/watcher.rb +11 -3
- 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: d97512d549606ea52367df080d5c7fe181f894595d804b31fe578ed5f1f26410
|
4
|
+
data.tar.gz: 9df7afe8818119e18391fd8b6284a2bf4ab40f87a75d0ca47979507e708395b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa935a49d7f9356ce6f0dc924b3fbf1bd9ba5c06923d45b893c92fb3e15df373dc6ce83d729b644bc0c9e6bef31f69f0804cf36e1acf5967ea66945da8e3f475
|
7
|
+
data.tar.gz: d196dc919ab630fb49f40e0c556c196948332aab5b672d68115d6a0dfb04e8c7691ff1270bd1c742eebbef11465c6034edd20d4ef05e413ce73574a410f3c6a4
|
data/lib/waldit/migration.rb
CHANGED
@@ -30,8 +30,8 @@ module Waldit
|
|
30
30
|
|
31
31
|
def create_waldit_publication
|
32
32
|
reversible do |dir|
|
33
|
-
dir.up { execute "CREATE PUBLICATION
|
34
|
-
dir.down { execute "DROP PUBLICATION
|
33
|
+
dir.up { execute "CREATE PUBLICATION waldit_publication" }
|
34
|
+
dir.down { execute "DROP PUBLICATION waldit_publication" }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,10 +39,10 @@ module Waldit
|
|
39
39
|
reversible do |dir|
|
40
40
|
dir.up do
|
41
41
|
execute "ALTER TABLE #{table} REPLICA IDENTITY FULL"
|
42
|
-
execute "ALTER PUBLICATION
|
42
|
+
execute "ALTER PUBLICATION waldit_publication ADD TABLE #{table}"
|
43
43
|
end
|
44
44
|
dir.down do
|
45
|
-
execute "ALTER PUBLICATION
|
45
|
+
execute "ALTER PUBLICATION waldit_publication DROP TABLE #{table}"
|
46
46
|
execute "ALTER TABLE #{table} REPLICA IDENTITY DEFAULT"
|
47
47
|
end
|
48
48
|
end
|
@@ -51,12 +51,12 @@ module Waldit
|
|
51
51
|
def remove_table_from_waldit(table)
|
52
52
|
reversible do |dir|
|
53
53
|
dir.up do
|
54
|
-
execute "ALTER PUBLICATION
|
54
|
+
execute "ALTER PUBLICATION waldit_publication DROP TABLE #{table}"
|
55
55
|
execute "ALTER TABLE #{table} REPLICA IDENTITY DEFAULT"
|
56
56
|
end
|
57
57
|
dir.down do
|
58
58
|
execute "ALTER TABLE #{table} REPLICA IDENTITY FULL"
|
59
|
-
execute "ALTER PUBLICATION
|
59
|
+
execute "ALTER PUBLICATION waldit_publication ADD TABLE #{table}"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
data/lib/waldit/version.rb
CHANGED
data/lib/waldit/watcher.rb
CHANGED
@@ -13,18 +13,22 @@ module Waldit
|
|
13
13
|
|
14
14
|
case event
|
15
15
|
when InsertEvent
|
16
|
-
|
16
|
+
new_attributes = clean_attributes(event.table, event.new)
|
17
|
+
@connection.exec_prepared("waldit_insert", audit + [new_attributes.to_json])
|
17
18
|
|
18
19
|
when UpdateEvent
|
19
20
|
return if event.diff.without(ignored_columns(event.table)).empty?
|
20
|
-
|
21
|
+
old_attributes = clean_attributes(event.table, event.old)
|
22
|
+
new_attributes = clean_attributes(event.table, event.new)
|
23
|
+
|
24
|
+
@connection.exec_prepared("waldit_update", audit + [old_attributes.to_json, new_attributes.to_json])
|
21
25
|
|
22
26
|
when DeleteEvent
|
23
27
|
case @connection.exec_prepared("waldit_delete_cleanup", [event.transaction_id, event.table, event.primary_key]).values
|
24
28
|
in [["update", previous_old]]
|
25
29
|
@connection.exec_prepared("waldit_delete", audit + [previous_old])
|
26
30
|
in []
|
27
|
-
@connection.exec_prepared("waldit_delete", audit + [event.old.to_json])
|
31
|
+
@connection.exec_prepared("waldit_delete", audit + [clean_attributes(event.table, event.old).to_json])
|
28
32
|
else
|
29
33
|
# Don't need to audit anything on this case
|
30
34
|
end
|
@@ -111,6 +115,10 @@ module Waldit
|
|
111
115
|
Waldit.ignored_columns.call(table)
|
112
116
|
end
|
113
117
|
|
118
|
+
def clean_attributes(table, attributes)
|
119
|
+
attributes.without(ignored_columns(table))
|
120
|
+
end
|
121
|
+
|
114
122
|
def max_transaction_size
|
115
123
|
Waldit.max_transaction_size
|
116
124
|
end
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Navarro
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-08-
|
10
|
+
date: 2025-08-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: wal
|