CREATE TABLE IF NOT EXISTS issue (
    id UUID PRIMARY KEY,
    project UUID NOT NULL,
    number BIGINT NOT NULL,
    title VARCHAR(255) NOT NULL,
    body TEXT,
    state VARCHAR(255) NOT NULL,
    author UUID NOT NULL,
    milestone VARCHAR(255),
    created_at TIMESTAMPTZ NOT NULL,
    updated_at TIMESTAMPTZ NOT NULL,
    closed_at TIMESTAMPTZ,
    created_by_ai BOOLEAN NOT NULL DEFAULT false
);

CREATE INDEX idx_issue_project ON issue (project);
CREATE INDEX idx_issue_author ON issue (author);
CREATE INDEX idx_issue_state ON issue (state);
