125-scan-email-sequence-cron.sql
1 -- Migration 125: Register send-scan-email-sequence cron job 2 -- 3 -- Runs every 10 minutes. Checks scan_email_sequence for rows where 4 -- status = 'active' AND next_send_at <= NOW(), then fires emails. 5 -- 6 -- NOTE: cron_jobs lives in ops.db — run against ops.db, not sites.db: 7 -- sqlite3 db/ops.db < db/migrations/125-scan-email-sequence-cron.sql 8 9 INSERT OR IGNORE INTO cron_jobs 10 (name, task_key, description, handler_type, handler_value, 11 interval_value, interval_unit, enabled, timeout_seconds) 12 VALUES 13 ( 14 'Send Scan Email Sequence', 15 'sendScanEmailSequence', 16 'Sends post-scan nurture emails to opted-in non-purchasers. 7-email sequence over 14 days, 3 score-band segments (A/B/C). Runs every 10 min and fires emails whose next_send_at has passed within the local 9am-6pm Mon-Fri window.', 17 'function', 18 'sendScanEmailSequence', 19 10, 20 'minutes', 21 1, 22 60 23 );