CREATE TABLE IF NOT EXISTS room_thread (
    id UUID PRIMARY KEY,
    room UUID NOT NULL,
    parent BIGINT NOT NULL,
    created_by UUID NOT NULL,
    participants JSONB NOT NULL,
    last_message_at TIMESTAMPTZ NOT NULL,
    last_message_preview TEXT,
    created_at TIMESTAMPTZ NOT NULL,
    updated_at TIMESTAMPTZ NOT NULL
);

CREATE INDEX idx_room_thread_room ON room_thread (room);
