move to 2.5.5
[anni] / priv / repo / migrations / 20200808173046_only_expire_creates.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Repo.Migrations.OnlyExpireCreates do
6   use Ecto.Migration
7
8   def up do
9     statement = """
10     DELETE FROM
11       activity_expirations a_exp USING activities a, objects o
12     WHERE
13       a_exp.activity_id = a.id AND (o.data->>'id') = COALESCE(a.data->'object'->>'id', a.data->>'object')
14       AND (a.data->>'type' != 'Create' OR o.data->>'type' != 'Note');
15     """
16
17     execute(statement)
18   end
19
20   def down do
21     :ok
22   end
23 end