From 2e7c5fe2ded095c95f8596970d8fc3aaf0128f1b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 8 Aug 2020 12:33:37 -0500 Subject: Add migration to remove invalid activity expirations --- .../20200808173046_only_expire_creates.exs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 priv/repo/migrations/20200808173046_only_expire_creates.exs (limited to 'priv/repo') diff --git a/priv/repo/migrations/20200808173046_only_expire_creates.exs b/priv/repo/migrations/20200808173046_only_expire_creates.exs new file mode 100644 index 000000000..5a34dc7c1 --- /dev/null +++ b/priv/repo/migrations/20200808173046_only_expire_creates.exs @@ -0,0 +1,20 @@ +defmodule Pleroma.Repo.Migrations.OnlyExpireCreates do + use Ecto.Migration + + def up do + statement = """ + DELETE FROM + activity_expirations A USING activities B + WHERE + A.activity_id = B.id + AND B.local = false + AND B.data->>'type' != 'Create'; + """ + + execute(statement) + end + + def down do + :ok + end +end -- cgit v1.2.3 From 761cc5b4a2b4c0ef610ae7296f614ec4c9ceccad Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 8 Aug 2020 12:44:18 -0500 Subject: Don't filter on local --- priv/repo/migrations/20200808173046_only_expire_creates.exs | 1 - 1 file changed, 1 deletion(-) (limited to 'priv/repo') diff --git a/priv/repo/migrations/20200808173046_only_expire_creates.exs b/priv/repo/migrations/20200808173046_only_expire_creates.exs index 5a34dc7c1..42fb73375 100644 --- a/priv/repo/migrations/20200808173046_only_expire_creates.exs +++ b/priv/repo/migrations/20200808173046_only_expire_creates.exs @@ -7,7 +7,6 @@ defmodule Pleroma.Repo.Migrations.OnlyExpireCreates do activity_expirations A USING activities B WHERE A.activity_id = B.id - AND B.local = false AND B.data->>'type' != 'Create'; """ -- cgit v1.2.3 From 57b455de5a378d661eb794c2c9d75a2684d74ef3 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Wed, 12 Aug 2020 12:41:47 +0300 Subject: leave expirations with Create and Note types --- priv/repo/migrations/20200808173046_only_expire_creates.exs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'priv/repo') diff --git a/priv/repo/migrations/20200808173046_only_expire_creates.exs b/priv/repo/migrations/20200808173046_only_expire_creates.exs index 42fb73375..9df52956f 100644 --- a/priv/repo/migrations/20200808173046_only_expire_creates.exs +++ b/priv/repo/migrations/20200808173046_only_expire_creates.exs @@ -4,10 +4,10 @@ defmodule Pleroma.Repo.Migrations.OnlyExpireCreates do def up do statement = """ DELETE FROM - activity_expirations A USING activities B + activity_expirations a_exp USING activities a, objects o WHERE - A.activity_id = B.id - AND B.data->>'type' != 'Create'; + a_exp.activity_id = a.id AND (o.data->>'id') = COALESCE(a.data->'object'->>'id', a.data->>'object') + AND (a.data->>'type' != 'Create' OR o.data->>'type' != 'Note'); """ execute(statement) -- cgit v1.2.3