DB prune: Check if user follows hashtag with no objects before deletion

This commit is contained in:
Phantasm 2025-10-14 22:59:15 +02:00 committed by Phantasm
commit e32ab8aef2
2 changed files with 7 additions and 1 deletions

View file

@ -226,7 +226,12 @@ defmodule Mix.Tasks.Pleroma.Database do
DELETE FROM hashtags AS ht
WHERE NOT EXISTS (
SELECT 1 FROM hashtags_objects hto
WHERE ht.id = hto.hashtag_id)
WHERE ht.id = hto.hashtag_id
)
AND NOT EXISTS (
SELECT 1 FROM user_follows_hashtag ufh
WHERE ht.id = ufh.hashtag_id
)
"""
|> Repo.query()