CREATE TABLE IF NOT EXISTS pull_request (
    repo UUID NOT NULL,
    number BIGINT NOT NULL,
    issue UUID NOT NULL,
    title VARCHAR(255) NOT NULL,
    body TEXT,
    author UUID NOT NULL,
    base VARCHAR(255) NOT NULL,
    head VARCHAR(255) NOT NULL,
    status VARCHAR(255) NOT NULL,
    merged_by UUID,
    created_at TIMESTAMPTZ NOT NULL,
    updated_at TIMESTAMPTZ NOT NULL,
    merged_at TIMESTAMPTZ,
    created_by_ai BOOLEAN NOT NULL DEFAULT false,
    PRIMARY KEY (repo, number)
);

CREATE INDEX idx_pull_request_repo ON pull_request (repo);
CREATE INDEX idx_pull_request_author ON pull_request (author);
CREATE INDEX idx_pull_request_status ON pull_request (status);
