CREATE TABLE chat_bots (
    id BIGINT PRIMARY KEY,
    project_id BIGINT NOT NULL REFERENCES projects(id),
    chat_bot_platform_id BIGINT NOT NULL REFERENCES chat_bot_platforms(id),
    user_id BIGINT NOT NULL REFERENCES users(id),
    bot_id VARCHAR(50) NOT NULL,

    deleted BOOLEAN NOT NULL,

    created_at TIMESTAMP WITH TIME ZONE NOT NULL,
    updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
    deleted_at TIMESTAMP WITH TIME ZONE
);

CREATE SEQUENCE chat_bots_id_seq;

CREATE UNIQUE INDEX chat_bots_uniq ON chat_bots(project_id, user_id) WHERE deleted = FALSE;
