From c559c240d1a56f05fc70f69ae6b8c0809026fa2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne?= Date: Sun, 7 Aug 2022 20:41:24 +0200 Subject: [PATCH] Migrations: delete context objects These objects represent from 30 to 70% of the rows on the objects table, based on numbers from a few live instances (single-user, small, large.) As those pseudo-objects prevent creating objects with those actual IDs, deleting them is a better solution. This could have happened if an object used another object's ID as its context. --- ...5023_data_migration_delete_context_objects.exs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs diff --git a/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs b/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs new file mode 100644 index 000000000..debb474b2 --- /dev/null +++ b/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs @@ -0,0 +1,15 @@ +defmodule Pleroma.Repo.Migrations.DataMigrationDeleteContextObjects do + use Ecto.Migration + + require Logger + + @doc "This migration removes objects created exclusively for contexts, containing only an `id` field." + + def change do + Logger.warn( + "This migration can take a very long time to execute, depending on your database size. Please be patient, Pleroma-tan is doing her best!\n" + ) + + execute("DELETE FROM objects WHERE (data->>'type') IS NULL;") + end +end