CREATE TABLE IF NOT EXISTS repo_upstream (
    id BIGSERIAL PRIMARY KEY,
    repo_uuid UUID NOT NULL,
    source_url VARCHAR(255) NOT NULL,
    direction VARCHAR(255) NOT NULL,
    schedule_cron VARCHAR(255),
    last_run_at TIMESTAMPTZ,
    next_run_at TIMESTAMPTZ,
    status VARCHAR(255) NOT NULL,
    created_at TIMESTAMPTZ NOT NULL,
    updated_at TIMESTAMPTZ NOT NULL,
    UNIQUE (repo_uuid)
);

CREATE UNIQUE INDEX idx_repo_upstream_repo ON repo_upstream (repo_uuid);
