--- webhook-endpoints

create table webhooks (
    id number(19) primary key,
    project_id number(19) not null references projects(id),
    type varchar2(64 char) not null,
    title varchar2(64 char) not null,
    description varchar2(255 char) not null,
    url varchar2(255 char) not null,

    enabled number(1) not null,
    deleted number(1) 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 webhooks_id_seq;

create unique index webhooks_uniq on webhooks(
    case when deleted = 0
        then project_id
    end,
    case when deleted = 0
        then lower(title)
    end
);

