CREATE TABLE repositories (
    id text PRIMARY KEY,
    gitea_id bigint NOT NULL UNIQUE CHECK (gitea_id > 0),
    owner text NOT NULL,
    name text NOT NULL,
    full_name text NOT NULL,
    clone_url text NOT NULL DEFAULT '',
    default_branch text NOT NULL DEFAULT '',
    created_at timestamptz NOT NULL DEFAULT now(),
    updated_at timestamptz NOT NULL DEFAULT now(),
    UNIQUE (owner, name)
);

CREATE TABLE webhook_deliveries (
    delivery_id text PRIMARY KEY,
    event text NOT NULL,
    event_type text NOT NULL DEFAULT '',
    payload_sha256 text NOT NULL,
    received_at timestamptz NOT NULL DEFAULT now()
);

