-- Migration 090: Seed the tickets-reconcile sync schedule (STOPGAP).
--
-- The sync_scheduler.createDefaultSchedules() path only seeds defaults on a
-- virgin sync_schedules table; this migration covers existing installs.
-- Idempotent via ON CONFLICT (id) DO NOTHING.

INSERT INTO sync_schedules (
  id,
  name,
  description,
  cron_expression,
  sync_type,
  years_back,
  is_enabled
) VALUES (
  'tickets-reconcile',
  'Tickets Reconciliation',
  'STOPGAP backstop: re-fetches stale-open tickets (>7d since last sync) from Autotask and reconciles status / soft-deletes missing rows. Runs daily at 4:30 AM. Capped at 500 tickets per run.',
  '30 4 * * *',
  'tickets-reconcile',
  NULL,
  false
)
ON CONFLICT (id) DO NOTHING;
