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.
This commit is contained in:
parent
bb02ee99f5
commit
88c1c76d3e
6 changed files with 173 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue