CREATE TABLE IF NOT EXISTS messages (
    id UUID PRIMARY KEY NOT NULL,
    channel_id UUID NOT NULL REFERENCES channels (id) ON DELETE RESTRICT,
    project_id UUID NOT NULL REFERENCES projects (id) ON DELETE RESTRICT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    sent_at TIMESTAMPTZ,
    message TEXT NOT NULL
);
CREATE INDEX ON messages (channel_id);
CREATE INDEX ON messages (created_at);
CREATE INDEX ON messages (sent_at);
