20 lines
884 B
SQL
20 lines
884 B
SQL
-- Track when a feedback row was resolved.
|
|
--
|
|
-- NULL = still open. Non-NULL = closed at that moment. The action is
|
|
-- one-way: the resolve endpoint enforces `WHERE resolved_at IS NULL` so
|
|
-- a row already marked stays marked, and a subsequent re-resolve is a
|
|
-- no-op (no new email goes out).
|
|
--
|
|
-- We don't store "who" resolved it because the /stats page surfaces
|
|
-- this to the team and any audit-quality "who closed what" trail would
|
|
-- want its own table — out of scope for now.
|
|
ALTER TABLE feedback
|
|
ADD COLUMN IF NOT EXISTS resolved_at TIMESTAMPTZ;
|
|
|
|
-- Partial index makes "give me the still-open feedback" cheap as the
|
|
-- table grows. The /stats page lists newest-first regardless of state,
|
|
-- so the existing created_at index still serves its read path.
|
|
CREATE INDEX IF NOT EXISTS idx_feedback_unresolved
|
|
ON feedback (created_at DESC)
|
|
WHERE resolved_at IS NULL;
|