CREATE TABLE incident_notes ( id uuid PRIMARY KEY, incident_id uuid NOT NULL REFERENCES incidents(id) ON DELETE CASCADE, author text NOT NULL CHECK (char_length(author) BETWEEN 1 AND 160), body text NOT NULL CHECK (char_length(body) BETWEEN 1 AND 2000), created_at timestamptz NOT NULL DEFAULT now() ); CREATE INDEX incident_notes_history_idx ON incident_notes (incident_id, created_at ASC, id ASC);