-- 0089_website_submissions_utm.sql
--
-- Capture UTM attribution columns on website_submissions so the
-- Marketing report (and downstream attribution analysis) can group
-- inquiries by campaign / source / medium without re-parsing the JSON
-- payload on every read.
--
-- All five columns are nullable: UTM presence is opportunistic
-- (driven by whatever the marketing site's tracker plumbed through),
-- not a hard requirement on intake. Index over (port_id, utm_source,
-- received_at) makes "campaign performance for the last 90 days" a
-- single index scan.

ALTER TABLE website_submissions
  ADD COLUMN utm_source text,
  ADD COLUMN utm_medium text,
  ADD COLUMN utm_campaign text,
  ADD COLUMN utm_term text,
  ADD COLUMN utm_content text;

CREATE INDEX idx_ws_utm_source
  ON website_submissions (port_id, utm_source, received_at);
