From 4bb57d4f25bcdc90a63163ba175b6171c9ddbc33 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 20 Jan 2024 18:47:25 -0500 Subject: [PATCH] Use config to control background migrators --- config/benchmark.exs | 3 +++ config/config.exs | 1 + config/test.exs | 1 + lib/pleroma/application.ex | 15 ++++++++++----- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config/benchmark.exs b/config/benchmark.exs index e3e1118ed..848344864 100644 --- a/config/benchmark.exs +++ b/config/benchmark.exs @@ -79,6 +79,9 @@ IO.puts("RUM enabled: #{rum_enabled}") config :pleroma, Pleroma.ReverseProxy.Client, Pleroma.ReverseProxy.ClientMock +config :pleroma, Pleroma.Application, + background_migrators: false + if File.exists?("./config/benchmark.secret.exs") do import_config "benchmark.secret.exs" else diff --git a/config/config.exs b/config/config.exs index c6a12a7b2..be9ddba53 100644 --- a/config/config.exs +++ b/config/config.exs @@ -905,6 +905,7 @@ config :pleroma, Pleroma.Search.Meilisearch, initial_indexing_chunk_size: 100_000 config :pleroma, Pleroma.Application, + background_migrators: true, internal_fetch: true, load_custom_modules: true, max_restarts: 3 diff --git a/config/test.exs b/config/test.exs index 0a6688823..898b0828e 100644 --- a/config/test.exs +++ b/config/test.exs @@ -163,6 +163,7 @@ peer_module = config :pleroma, Pleroma.Cluster, peer_module: peer_module config :pleroma, Pleroma.Application, + background_migrators: false, internal_fetch: false, load_custom_modules: false, max_restarts: 100 diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index de7d06974..2eda212b3 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -108,6 +108,7 @@ defmodule Pleroma.Application do ] ++ task_children() ++ dont_run_in_test(@mix_env) ++ + background_migrators() ++ shout_child(shout_enabled?()) ++ [Pleroma.Gopher.Server] @@ -218,14 +219,18 @@ defmodule Pleroma.Application do keys: :duplicate, partitions: System.schedulers_online() ]} - ] ++ background_migrators() + ] end defp background_migrators do - [ - Pleroma.Migrators.HashtagsTableMigrator, - Pleroma.Migrators.ContextObjectsDeletionMigrator - ] + if Application.get_env(:pleroma, __MODULE__)[:background_migrators] do + [ + Pleroma.Migrators.HashtagsTableMigrator, + Pleroma.Migrators.ContextObjectsDeletionMigrator + ] + else + [] + end end defp shout_child(true) do