summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2022-08-24 14:06:00 +0200
committerYorhel <git@yorhel.nl>2022-08-24 14:06:02 +0200
commitb3daafde4a7a1cb4076b9a218e3258d34db313dd (patch)
tree1b7dbc3a008e533520498c7633ac0c98f372958c /util
parent0f2d0f3b1bd6e0ef43f268c3bb14a79a824e1e44 (diff)
Use libloc to add IP location information to the DB
This should save me considerable time in finding duplicate account voters.
Diffstat (limited to 'util')
-rw-r--r--util/updates/2022-08-24-ipinfo.sql17
1 files changed, 17 insertions, 0 deletions
diff --git a/util/updates/2022-08-24-ipinfo.sql b/util/updates/2022-08-24-ipinfo.sql
new file mode 100644
index 00000000..ffa00708
--- /dev/null
+++ b/util/updates/2022-08-24-ipinfo.sql
@@ -0,0 +1,17 @@
+CREATE TYPE ipinfo AS (
+ ip inet,
+ country text,
+ asn integer,
+ as_name text,
+ anonymous_proxy boolean,
+ sattelite_provider boolean,
+ anycast boolean,
+ drop boolean
+);
+
+ALTER TABLE audit_log ALTER COLUMN by_ip TYPE ipinfo USING ROW(by_ip,null,null,null,null,null,null,null);
+ALTER TABLE reports ALTER COLUMN ip TYPE ipinfo USING CASE WHEN ip IS NULL THEN NULL ELSE ROW(ip,null,null,null,null,null,null,null)::ipinfo END;
+
+ALTER TABLE users_shadow ALTER COLUMN ip DROP DEFAULT;
+ALTER TABLE users_shadow ALTER COLUMN ip DROP NOT NULL;
+ALTER TABLE users_shadow ALTER COLUMN ip TYPE ipinfo USING CASE WHEN ip = '0.0.0.0' THEN NULL ELSE ROW(ip,null,null,null,null,null,null,null)::ipinfo END;