logidze 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/circle.yml +1 -1
- data/lib/generators/logidze/install/templates/migration.rb.erb +16 -3
- data/lib/logidze/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 309c5da695723e3a3f1c6e73b5c9ba71826880a8
|
4
|
+
data.tar.gz: bab3825e840c655022920bea787059d156643114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32fc59a0145c74c8334c6990f90481ddece3c3045d79119a260a33d65d6d9236ad54e567fd92dd74705bfb51dc52cea8d0c08356fa1426f15624316a1f6fc882
|
7
|
+
data.tar.gz: '080f5c26aa1d1559bdb97b11d141be46e08f6b22f1a1282c07410e75b5b92633aecb2c179490552d1a9e3b61aa113d7c46333e72a753eb80d079fbea1a87c729'
|
data/CHANGELOG.md
CHANGED
data/circle.yml
CHANGED
@@ -112,6 +112,8 @@ class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VE
|
|
112
112
|
CREATE OR REPLACE FUNCTION logidze_logger() RETURNS TRIGGER AS $body$
|
113
113
|
DECLARE
|
114
114
|
changes jsonb;
|
115
|
+
version jsonb;
|
116
|
+
snapshot jsonb;
|
115
117
|
new_v integer;
|
116
118
|
size integer;
|
117
119
|
history_limit integer;
|
@@ -127,13 +129,19 @@ class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VE
|
|
127
129
|
columns_blacklist := TG_ARGV[2];
|
128
130
|
|
129
131
|
IF TG_OP = 'INSERT' THEN
|
132
|
+
snapshot = logidze_snapshot(to_jsonb(NEW.*), ts_column, columns_blacklist);
|
130
133
|
|
131
|
-
|
134
|
+
IF snapshot#>>'{h, -1, c}' != '{}' THEN
|
135
|
+
NEW.log_data := snapshot;
|
136
|
+
END IF;
|
132
137
|
|
133
138
|
ELSIF TG_OP = 'UPDATE' THEN
|
134
139
|
|
135
140
|
IF OLD.log_data is NULL OR OLD.log_data = '{}'::jsonb THEN
|
136
|
-
|
141
|
+
snapshot = logidze_snapshot(to_jsonb(NEW.*), ts_column, columns_blacklist);
|
142
|
+
IF snapshot#>>'{h, -1, c}' != '{}' THEN
|
143
|
+
NEW.log_data := snapshot;
|
144
|
+
END IF;
|
137
145
|
RETURN NEW;
|
138
146
|
END IF;
|
139
147
|
|
@@ -175,11 +183,16 @@ class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VE
|
|
175
183
|
new_v := (NEW.log_data#>>'{h,-1,v}')::int + 1;
|
176
184
|
|
177
185
|
size := jsonb_array_length(NEW.log_data->'h');
|
186
|
+
version := logidze_version(new_v, changes, ts, columns_blacklist);
|
187
|
+
|
188
|
+
IF version->>'c' = '{}' THEN
|
189
|
+
RETURN NEW;
|
190
|
+
END IF;
|
178
191
|
|
179
192
|
NEW.log_data := jsonb_set(
|
180
193
|
NEW.log_data,
|
181
194
|
ARRAY['h', size::text],
|
182
|
-
|
195
|
+
version,
|
183
196
|
true
|
184
197
|
);
|
185
198
|
|
data/lib/logidze/version.rb
CHANGED
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: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|