Files
pn-new-crm/src/lib/db/migrations/0045_website_submissions_triage.sql

19 lines
786 B
MySQL
Raw Normal View History

-- Inquiry-inbox triage workflow. Adds three columns to
-- website_submissions so the inbox isn't permanent dead weight:
--
-- triage_state: 'open' | 'converted' | 'dismissed' | 'assigned'
-- triaged_at: timestamptz when the state last changed
-- triaged_by: user id who set the state
--
-- Default 'open' so backfill leaves history visible. The default
-- inbox query filters to open + assigned so resolved/dismissed roll
-- off without being permanently lost.
ALTER TABLE website_submissions
ADD COLUMN IF NOT EXISTS triage_state text NOT NULL DEFAULT 'open',
ADD COLUMN IF NOT EXISTS triaged_at timestamptz,
ADD COLUMN IF NOT EXISTS triaged_by text;
CREATE INDEX IF NOT EXISTS idx_ws_triage_state
ON website_submissions (port_id, triage_state, received_at DESC);