Yes, pg_cron runs inside your database. Enable it under Integrations (or create extension pg_cron;).
The archive part is plain SQL:
select cron.schedule('archive-old-bookings', '0 2 * * *', $$
update public.bookings set archived = true
where created_at < now() - interval '30 days' and not archived;
$$);For the email, write an edge function and call it from cron with pg_net:
select cron.schedule('nightly-summary', '5 2 * * *', $$
select net.http_post(
url := 'https://<ref>.supabase.co/functions/v1/nightly-summary',
headers := jsonb_build_object('Authorization', 'Bearer ' || (select decrypted_secret from vault.decrypted_secrets where name = 'cron_key'))
);
$$);Store the key in Vault like that rather than pasting it into the job. Times are in UTC. Check cron.job_run_details to see if runs succeeded.