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 FW-59 edge function fw-webhook-maintenance handles log retention purging and expired secret deactivation.

Prerequisites

Enable extensions in the Supabase Dashboard → Extensions:
  • pg_cron
  • pg_net
Ensure util.invoke_edge_function is available and app.settings.service_role_key is configured in Vault.

Scheduling SQL

Run this in the Supabase SQL Editor (NOT as a migration — it uses project-specific Vault settings):
-- Webhook maintenance: log retention purge + expired secret deactivation — daily at 2 AM UTC
SELECT cron.schedule(
  'fw-webhook-maintenance',
  '0 2 * * *',
  $$SELECT util.invoke_edge_function('fw-webhook-maintenance', '{}'::jsonb);$$
);

Verification

-- Verify the job is registered
SELECT jobid, jobname, schedule, command
FROM cron.job
WHERE jobname = 'fw-webhook-maintenance';

-- Check recent run history
SELECT jobid, job_name, status, return_message, start_time, end_time
FROM cron.job_run_details
WHERE job_name = 'fw-webhook-maintenance'
ORDER BY start_time DESC
LIMIT 20;

Managing the Cron Job

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

-- Pause the maintenance job (unschedule)
SELECT cron.unschedule('fw-webhook-maintenance');

-- Re-enable after pause
SELECT cron.schedule(
  'fw-webhook-maintenance',
  '0 2 * * *',
  $$SELECT util.invoke_edge_function('fw-webhook-maintenance', '{}'::jsonb);$$
);

What It Does

TaskScheduleDescription
Log retention purgeDaily 2 AM UTCDeletes fw_webhook_logs rows older than 90 days (paginated, 1000 per batch)
Expired secret deactivationDaily 2 AM UTCSets is_active = false on fw_webhook_secrets where expires_at < now()

Troubleshooting

SymptomCheck
Job not runningSELECT * FROM cron.job WHERE jobname = 'fw-webhook-maintenance'; — is it registered?
Logs not being purgedCheck Edge Function logs for errors. Verify fw_webhook_logs has rows older than 90 days.
Secrets not deactivatedVerify secrets have expires_at set and it’s in the past.
Edge function errorsCheck Edge Function logs in Supabase Dashboard.