new-site/api/migrations/095_fmcsa_ifta_self_filed.sql
justin 3d4226e95c ifta: 3-touch business-day cadence + 'I already filed it' suppression
- Multi-touch reminders at 10/7/4 BUSINESS days before each deadline (weekends
  skipped; biz-day math so a touch never lands purely on a weekend with no
  runway). Escalating tone soft -> urgent -> last-chance, with the 'almost too
  late to DIY, we can still file it' angle so it's a convenience sale, not a free
  reminder service. ifta_touch_no tracks the highest touch sent so each touch
  hits only carriers below that level; never repeats a touch.
- 'I already filed it' one-click link: HMAC-tokenized GET /api/v1/ifta/filed
  (token matches between Python builder and api/src/routes/ifta.ts -- verified
  identical output), records ifta_self_filed_at, friendly confirmation page,
  stops further touches this cycle + gives DIY-vs-prospect signal. Builder
  excludes self-filed carriers.
- migration 094 (ifta_touch_no) + 095 (ifta_self_filed_at); cycle reset clears
  both each new quarter. Verified: biz-day touch schedule, token cross-match.
2026-06-13 23:41:14 -05:00

12 lines
592 B
SQL

-- "I already filed it" suppression for IFTA quarterly reminders.
-- When a carrier clicks the one-click "I already filed it" link in a reminder
-- email, we record it here: it stops further touches THIS cycle (the IFTA
-- builder excludes self-filed carriers) and gives us DIY-vs-prospect signal.
-- Reset each new quarter alongside ifta_reminded_at.
ALTER TABLE fmcsa_carriers
ADD COLUMN IF NOT EXISTS ifta_self_filed_at TIMESTAMPTZ;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_fmcsa_carriers_ifta_self_filed
ON fmcsa_carriers (ifta_self_filed_at)
WHERE ifta_self_filed_at IS NULL;