summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-04-16 09:22:09 +0200
committerYorhel <git@yorhel.nl>2020-04-16 09:22:13 +0200
commit074d00452f5e1a18decd80068d18e602e857f674 (patch)
tree817b78b03884787eb085e544e4a1feb97271d03c /util
parent50e4f6602459b3b0d2ec1695e06630e079580e9a (diff)
imgflag: Fix uid integrity + properly handle user account deletion
I made sure that the image_votes.uid column could be NULL, but then forgot to add the foreign key reference to make this machinery work. I've split the image_votes_cache trigger in two parts as a performance improvement - there's no need to update the cache then the uid or date changes. Otherwise deleting a user account with many image votes may take a few minutes.
Diffstat (limited to 'util')
-rw-r--r--util/updates/2020-04-16-imgflag-user-deletion.sql4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/updates/2020-04-16-imgflag-user-deletion.sql b/util/updates/2020-04-16-imgflag-user-deletion.sql
new file mode 100644
index 00000000..f8f21ac1
--- /dev/null
+++ b/util/updates/2020-04-16-imgflag-user-deletion.sql
@@ -0,0 +1,4 @@
+ALTER TABLE image_votes ADD CONSTRAINT image_votes_uid_fkey FOREIGN KEY (uid) REFERENCES users (id) ON DELETE SET DEFAULT;
+
+DROP TRIGGER image_votes_cache ON image_votes;
+\i sql/triggers.sql