Merge develop branch upstream
[akkoma] / lib / mix / tasks / pleroma / database.ex
index 53ad58b6458c2d9721ca8a57c307281327a1b64b..57f73d12baa0bc70e6a11e243358a9c66aeec14e 100644 (file)
@@ -97,12 +97,10 @@ defmodule Mix.Tasks.Pleroma.Database do
     |> Repo.delete_all(timeout: :infinity)
 
     prune_hashtags_query = """
-    delete from hashtags
-    where id in (
-      select id from hashtags as ht
-      left join hashtags_objects as hto
-      on hto.hashtag_id = ht.id
-      where hto.hashtag_id is null)
+    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)