From 1654b7fd6128927d822b837cae251da70805f22f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 2 Jan 2022 12:24:15 -0600 Subject: Remove pleroma.database remove_embedded_objects mix task --- docs/administration/CLI_tasks/database.md | 19 +------------------ lib/mix/tasks/pleroma/database.ex | 23 ----------------------- test/mix/tasks/pleroma/database_test.exs | 21 --------------------- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/docs/administration/CLI_tasks/database.md b/docs/administration/CLI_tasks/database.md index c53c49921..86079776d 100644 --- a/docs/administration/CLI_tasks/database.md +++ b/docs/administration/CLI_tasks/database.md @@ -5,23 +5,6 @@ !!! danger These mix tasks can take a long time to complete. Many of them were written to address specific database issues that happened because of bugs in migrations or other specific scenarios. Do not run these tasks "just in case" if everything is fine your instance. -## Replace embedded objects with their references - -Replaces embedded objects with references to them in the `objects` table. Only needs to be ran once if the instance was created before Pleroma 1.0.5. The reason why this is not a migration is because it could significantly increase the database size after being ran, however after this `VACUUM FULL` will be able to reclaim about 20% (really depends on what is in the database, your mileage may vary) of the db size before the migration. - -=== "OTP" - - ```sh - ./bin/pleroma_ctl database remove_embedded_objects [option ...] - ``` - -=== "From Source" - - ```sh - mix pleroma.database remove_embedded_objects [option ...] - ``` - - ### Options - `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references @@ -144,7 +127,7 @@ but should only be run if necessary. **It is safe to cancel this.** ## Change Text Search Configuration -Change `default_text_search_config` for database and (if necessary) text_search_config used in index, then rebuild index (it may take time). +Change `default_text_search_config` for database and (if necessary) text_search_config used in index, then rebuild index (it may take time). === "OTP" diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex index 41a36851e..a87c2c2e6 100644 --- a/lib/mix/tasks/pleroma/database.ex +++ b/lib/mix/tasks/pleroma/database.ex @@ -20,29 +20,6 @@ defmodule Mix.Tasks.Pleroma.Database do @shortdoc "A collection of database related tasks" @moduledoc File.read!("docs/administration/CLI_tasks/database.md") - def run(["remove_embedded_objects" | args]) do - {options, [], []} = - OptionParser.parse( - args, - strict: [ - vacuum: :boolean - ] - ) - - start_pleroma() - Logger.info("Removing embedded objects") - - Repo.query!( - "update objects set data = safe_jsonb_set(data, '{object}'::text[], data->'object'->'id') where data->'object'->>'id' is not null;", - [], - timeout: :infinity - ) - - if Keyword.get(options, :vacuum) do - Maintenance.vacuum("full") - end - end - def run(["bump_all_conversations"]) do start_pleroma() Conversation.bump_for_all_activities() diff --git a/test/mix/tasks/pleroma/database_test.exs b/test/mix/tasks/pleroma/database_test.exs index 7a1a759da..d3b503a64 100644 --- a/test/mix/tasks/pleroma/database_test.exs +++ b/test/mix/tasks/pleroma/database_test.exs @@ -6,7 +6,6 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do use Pleroma.DataCase, async: true use Oban.Testing, repo: Pleroma.Repo - alias Pleroma.Activity alias Pleroma.Object alias Pleroma.Repo alias Pleroma.User @@ -24,26 +23,6 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do :ok end - describe "running remove_embedded_objects" do - test "it replaces objects with references" do - user = insert(:user) - {:ok, activity} = CommonAPI.post(user, %{status: "test"}) - new_data = Map.put(activity.data, "object", activity.object.data) - - {:ok, activity} = - activity - |> Activity.change(%{data: new_data}) - |> Repo.update() - - assert is_map(activity.data["object"]) - - Mix.Tasks.Pleroma.Database.run(["remove_embedded_objects"]) - - activity = Activity.get_by_id_with_object(activity.id) - assert is_binary(activity.data["object"]) - end - end - describe "prune_objects" do test "it prunes old objects from the database" do insert(:note) -- cgit v1.2.3