From: Mark Felder Date: Wed, 27 May 2020 21:27:07 +0000 (-0500) Subject: Permit easy access to vaccum full and analyze via a mix task X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=a2f57bd82b1b495a754516231b56e53ae41c6b69;p=akkoma Permit easy access to vaccum full and analyze via a mix task --- diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex index 778de162f..c4f343f04 100644 --- a/lib/mix/tasks/pleroma/database.ex +++ b/lib/mix/tasks/pleroma/database.ex @@ -135,4 +135,30 @@ defmodule Mix.Tasks.Pleroma.Database do end) |> Stream.run() end + + def run(["vacuum", args]) do + start_pleroma() + + case args do + "analyze" -> + Logger.info("Runnning VACUUM ANALYZE.") + Repo.query!( + "vacuum analyze;", + [], + timeout: :infinity + ) + + "full" -> + Logger.info("Runnning VACUUM FULL. This could take a while.") + + Repo.query!( + "vacuum full;", + [], + timeout: :infinity + ) + + _ -> + Logger.error("Error: invalid vacuum argument.") + end + end end