diff --git a/supabase/migrations/20250324015132_add-pg_cron-job-to-delete-old-items.sql b/supabase/migrations/20250324015132_add-pg_cron-job-to-delete-old-items.sql new file mode 100644 index 00000000..1a708ca8 --- /dev/null +++ b/supabase/migrations/20250324015132_add-pg_cron-job-to-delete-old-items.sql @@ -0,0 +1,10 @@ +create EXTENSION if not exists pg_cron with schema pg_catalog; + +grant usage on schema cron to postgres; +grant all privileges on all tables in schema cron to postgres; + +select cron.schedule ( + 'monday-items-cleanup', + '0 11 * * 1', -- Monday at 11:00am (GMT) + $$ delete from public.items where created_at < NOW() - interval '6 months' $$ +);