CREATE TABLE telegram_publics (
    id BIGINT PRIMARY KEY,
    title varchar(125) not null,
    telegram_link varchar(512) not null,
    channel_id BIGINT references channels (id),
    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 telegram_publics_id_seq;

CREATE UNIQUE INDEX telegram_publics_uniq ON telegram_publics(telegram_link, channel_id) WHERE deleted = FALSE;
