CREATE TABLE chat_bots (
    id BIGINT IDENTITY(1, 1) 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 NVARCHAR(50) NOT NULL,

    [deleted] BIT NOT NULL,

    created_at DATETIMEOFFSET NOT NULL,
    updated_at DATETIMEOFFSET NOT NULL,
    deleted_at DATETIMEOFFSET
);

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