-- Executar via cron a cada 15 min (ou 1h) para encerrar vagas expiradas
-- mysql -u user -p database < cron-close-jobs.sql

UPDATE jobs
SET status = 'closed',
    closed_at = COALESCE(UTC_TIMESTAMP(), NOW())
WHERE status = 'published'
  AND publish_end_at < COALESCE(UTC_TIMESTAMP(), NOW());
