CREATE TABLE chat_bot_platforms (
    id BIGINT IDENTITY(1, 1) PRIMARY KEY,
    project_id BIGINT NOT NULL REFERENCES projects(id),
    [type] NVARCHAR(64) NOT NULL,
    title NVARCHAR(64) NOT NULL,
    title_lower AS LOWER([title]),
    description NVARCHAR(255) NOT NULL,
    [url] NVARCHAR(255) NOT NULL,
    login NVARCHAR(50),
    [password] NVARCHAR(50),

    [enabled] BIT NOT NULL,
    [deleted] BIT NOT NULL,

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

CREATE UNIQUE INDEX chat_bot_platforms_uniq ON chat_bot_platforms(project_id, title_lower) WHERE deleted = 0;
