
CREATE TABLE IF NOT EXISTS "webhook"
(
    id uuid,
    created timestamp NOT NULL,
    url varchar(256) NOT NULL,
    country char(2) NOT NULL,
    retry_count int NOT NULL,
    on_created bool NOT NULL,
    on_edited bool NOT NULL,
    on_deleted bool NOT NULL,

    primary key (id),
    constraint fk_country_id foreign key (country)
        references country(iso_name) on delete cascade on update cascade
);

CREATE TABLE IF NOT EXISTS "job"
(
    id uuid,
    webhook_id uuid NOT NULL,

    created timestamp NOT NULL,
    success bool NOT NULL,
    success_time timestamp NOT NULL,

    retry_count int NOT NULL,

    content varchar(1024) NOT NULL,

    primary key (id),
    constraint fk_webhook_id foreign key (webhook_id)
        references webhook(id) on delete cascade on update cascade
);