CREATE TABLE IF NOT EXISTS room_thread (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    room UUID NOT NULL REFERENCES room(id),
    seq BIGINT NOT NULL,
    starter_message UUID,
    title TEXT NOT NULL,
    created_by UUID NOT NULL,
    archived BOOLEAN NOT NULL DEFAULT FALSE,
    locked BOOLEAN NOT NULL DEFAULT FALSE,
    last_message_at TIMESTAMPTZ,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    archived_at TIMESTAMPTZ
);
