summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorHélène <pleroma-dev@helene.moe>2022-08-15 01:15:23 +0200
committerHélène <pleroma-dev@helene.moe>2022-08-15 01:47:09 +0200
commit88c1c76d3eca3412d1e02008f1b8d96fe8fe0b96 (patch)
treeda0e4065e3ed511f3c7ba4b0d40307b9da9f748c /priv
parentbb02ee99f58e378e33162211f41fe5979d5da8ae (diff)
Migrations: delete contexts with BaseMigrator
Due to the lengthiness of this task, the migration has been adapted into a BaseMigrator migration, running in the background instead.
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs13
1 files changed, 8 insertions, 5 deletions
diff --git a/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs b/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs
index debb474b2..84365dbe3 100644
--- a/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs
+++ b/priv/repo/migrations/20220807125023_data_migration_delete_context_objects.exs
@@ -3,13 +3,16 @@ defmodule Pleroma.Repo.Migrations.DataMigrationDeleteContextObjects do
require Logger
- @doc "This migration removes objects created exclusively for contexts, containing only an `id` field."
+ def up do
+ dt = NaiveDateTime.utc_now()
- 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(
+ "INSERT INTO data_migrations(name, inserted_at, updated_at) " <>
+ "VALUES ('delete_context_objects', '#{dt}', '#{dt}') ON CONFLICT DO NOTHING;"
)
+ end
- execute("DELETE FROM objects WHERE (data->>'type') IS NULL;")
+ def down do
+ execute("DELETE FROM data_migrations WHERE name = 'delete_context_objects';")
end
end