Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

The PF-46 edge function process-data-retention needs to be scheduled via pg_cron + pg_net in Supabase.

Prerequisites

Enable extensions in the Supabase Dashboard → Extensions:
  • pg_cron
  • pg_net

Scheduling SQL

Run these in the Supabase SQL Editor (NOT as a migration — they contain project-specific URLs and keys):
-- 1. Daily Archival — midnight UTC
SELECT cron.schedule(
  'pf-data-archival',
  '0 0 * * *',
  $$
  SELECT net.http_post(
    url := 'https://zkgxozahyczcnzpwhbbf.supabase.co/functions/v1/process-data-retention',
    headers := '{"Content-Type": "application/json", "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY"}'::jsonb,
    body := '{"action": "archive"}'::jsonb
  ) AS request_id;
  $$
);

-- 2. Daily Deletion — 1 AM UTC (after archival)
SELECT cron.schedule(
  'pf-data-deletion',
  '0 1 * * *',
  $$
  SELECT net.http_post(
    url := 'https://zkgxozahyczcnzpwhbbf.supabase.co/functions/v1/process-data-retention',
    headers := '{"Content-Type": "application/json", "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY"}'::jsonb,
    body := '{"action": "delete"}'::jsonb
  ) AS request_id;
  $$
);
Important: Replace YOUR_SERVICE_ROLE_KEY with the actual service role key from the Supabase dashboard (Settings → API → Service Role key). Never commit service role keys to code.

Managing Cron Jobs

-- List all scheduled jobs
SELECT * FROM cron.job;

-- Unschedule a job
SELECT cron.unschedule('pf-data-archival');
SELECT cron.unschedule('pf-data-deletion');

-- View job run history
SELECT * FROM cron.job_run_details ORDER BY start_time DESC LIMIT 20;