CREATE TABLE IF NOT EXISTS repo_webhook (
    id BIGSERIAL PRIMARY KEY,
    repo_uuid UUID NOT NULL,
    event JSONB NOT NULL,
    url VARCHAR(255),
    access_key VARCHAR(255),
    secret_key VARCHAR(255),
    created_at TIMESTAMPTZ NOT NULL,
    last_delivered_at TIMESTAMPTZ,
    touch_count BIGINT NOT NULL DEFAULT 0
);

CREATE INDEX idx_repo_webhook_repo ON repo_webhook (repo_uuid);
