CREATE TABLE chat_bot_platforms (
    id BIGINT PRIMARY KEY,
    project_id BIGINT NOT NULL REFERENCES projects(id),
    type VARCHAR(64) NOT NULL,
    title VARCHAR(64) NOT NULL,
    description VARCHAR(255) NOT NULL,
    url VARCHAR(255) NOT NULL,
    login VARCHAR(50),
    password VARCHAR(50),

    enabled BOOLEAN 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_bot_platforms_id_seq;

CREATE UNIQUE INDEX chat_bot_platforms_uniq ON chat_bot_platforms(project_id, LOWER(title)) WHERE deleted = FALSE;
