Merge remote-tracking branch 'pleroma/develop' into object-tombstone-visibility
[akkoma] / lib / mix / tasks / pleroma / database.ex
index e7f4b67a463d5b8b1dd540901b0db47e853d0a3b..57f73d12baa0bc70e6a11e243358a9c66aeec14e 100644 (file)
@@ -96,6 +96,15 @@ defmodule Mix.Tasks.Pleroma.Database do
     )
     |> Repo.delete_all(timeout: :infinity)
 
+    prune_hashtags_query = """
+    DELETE FROM hashtags AS ht
+    WHERE NOT EXISTS (
+      SELECT 1 FROM hashtags_objects hto
+      WHERE ht.id = hto.hashtag_id)
+    """
+
+    Repo.query(prune_hashtags_query)
+
     if Keyword.get(options, :vacuum) do
       Maintenance.vacuum("full")
     end