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    timestamp with time zone not null,
    updated_at    timestamp with time zone not null,
    merged_at     timestamp with time zone,
    created_by_ai boolean default false    not null,
    primary key (repo, number)
);

create index if not exists idx_pull_request_repo
    on pull_request (repo);

create index if not exists idx_pull_request_author
    on pull_request (author);

create index if not exists idx_pull_request_status
    on pull_request (status);
