-- Phase 1: N-way group rooms. -- The threads/thread_participants/thread_messages schema (0001) is already -- N-way; this adds only what rooms need for audit + UX. Existing rows default -- to kind='dm' so 1:1 routing is unchanged. ALTER TABLE threads ADD COLUMN kind TEXT NOT NULL DEFAULT 'dm' CHECK (kind IN ('dm', 'room')), ADD COLUMN created_by UUID REFERENCES agents (id); -- Soft-remove participants so message history stays attributable after someone -- leaves a room. added_by/joined_at record who pulled a participant in + when. ALTER TABLE thread_participants ADD COLUMN added_by UUID REFERENCES agents (id), ADD COLUMN joined_at TIMESTAMPTZ NOT NULL DEFAULT now(), ADD COLUMN active BOOLEAN NOT NULL DEFAULT true;