Skip to content

Commit 40cdfa7

Browse files
authored
Add db migration to update some votes results (#658)
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
1 parent 83d6372 commit 40cdfa7

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
update vote set
2+
results = jsonb_set(results, '{against_percentage}', to_jsonb((results->>'against')::real / (results->>'allowed_voters')::real * 100))
3+
where results is not null
4+
and results != 'null'::jsonb
5+
and not results ? 'against_percentage';
6+
7+
update vote set
8+
results = jsonb_set(results, '{pending_voters}', '[]'::jsonb)
9+
where results is not null
10+
and results != 'null'::jsonb
11+
and not results ? 'pending_voters';
12+
13+
---- create above / drop below ----

0 commit comments

Comments
 (0)