diff options
author | Hélène <pleroma-dev@helene.moe> | 2022-08-15 01:15:23 +0200 |
---|---|---|
committer | Hélène <pleroma-dev@helene.moe> | 2022-08-15 01:47:09 +0200 |
commit | 88c1c76d3eca3412d1e02008f1b8d96fe8fe0b96 (patch) | |
tree | da0e4065e3ed511f3c7ba4b0d40307b9da9f748c /priv | |
parent | bb02ee99f58e378e33162211f41fe5979d5da8ae (diff) | |
download | pleroma-88c1c76d3eca3412d1e02008f1b8d96fe8fe0b96.tar.gz |
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.exs | 13 |
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 |