8
Query to fix modlog (campfyre.nickwebster.dev)

The modlog page can break if anyone has been banned with an expiry too far into the future, I grabbed this query to fix it from the github issue a while back and refined it a little if it's useful to anyone:

BEGIN;
-- The modlog UI breaks for bans too far in the future
SELECT * FROM mod_ban WHERE expires > now() + INTERVAL '10 years';
-- Lets just make them permanent as an easy fix lol
UPDATE mod_ban SET expires = NULL WHERE expires > now() + INTERVAL '10 years';
-- See our changes
SELECT * FROM mod_ban WHERE expires > now() + INTERVAL '10 years';
ROLLBACK;
-- replace ROLBACK; with COMMIT; if you're happy

This will make any ban with an expiry >10 years into the future permanent and fix your modlog. If this happens a lot it might be worth making this a trigger in your lemmy db.

top 2 comments
sorted by: hot top controversial new old
[-] PriorProject@lemmy.world 1 points 1 year ago

Is there an issue for this in the GitHub project? It sounds like you've done the hard work of diagnosing the issue and an upstream fix seems likely a modest effort given this info.

[-] nick@campfyre.nickwebster.dev 3 points 1 year ago

Yes, there are a few issues in the lemmy-ui including this PR with a temp fix: https://github.com/LemmyNet/lemmy-ui/pull/2058

this post was submitted on 26 Aug 2023
8 points (100.0% liked)

Lemmy Support

4676 readers
50 users here now

Support / questions about Lemmy.

Matrix Space: #lemmy-space

founded 5 years ago
MODERATORS