mix pleroma.database set_text_search_config now runs concurrently and infinitely
[akkoma] / lib / mix / tasks / pleroma / database.ex
index bcde07774fb71b9365bec0bdc75169ebc4196aa6..a973beaa907740badee669c05f18456642db6081 100644 (file)
@@ -97,10 +97,10 @@ 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)
+    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)
@@ -209,7 +209,9 @@ defmodule Mix.Tasks.Pleroma.Database do
           new.fts_content := to_tsvector(new.data->>'content');
           RETURN new;
           END
-          $$ LANGUAGE plpgsql"
+          $$ LANGUAGE plpgsql",
+          [],
+          timeout: :infinity
         )
 
         shell_info("Refresh RUM index")
@@ -219,7 +221,9 @@ defmodule Mix.Tasks.Pleroma.Database do
 
         Ecto.Adapters.SQL.query!(
           Pleroma.Repo,
-          "CREATE INDEX objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); "
+          "CREATE INDEX CONCURRENTLY objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); ",
+          [],
+          timeout: :infinity
         )
       end