Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@Humpleupagus @cassidyclown @lina @mint
Something along the lines of
with
ids as (
select
activities.id as acitivity_id,
objects.id as object_id
from activities
join objects on
objects.data->>'id' = associated_object_id(activities.data) and
not (
activities.data::text like '%eveningzoo.club%' or
objects.data::text like '%eveningzoo.club%' or
greatest(activities.inserted_at, activities.updated_at, objects.inserted_at, objects.updated_at) >= now()-'30 days'::interval
)
),
del_activities as (
delete from activities where id in (select acitivity_id from ids)
)
delete from objects where id in (select object_id from ids)
But setup a DB and instance copy first to test it thoroughly without affecting your live instance.