| 1 | -- Pull requests: a request to merge one branch of a repository into another. |
| 2 | -- |
| 3 | -- **No `number` sequence of its own.** Numbers are allocated from `repo_sequences`, |
| 4 | -- the same table issues draw from, so `#7` names one thing on a repository whatever |
| 5 | -- kind of thing it is — which is what lets a bare `#7` in a body be a link somebody can |
| 6 | -- follow without knowing what they are following. `unique (repo_id, number)` here is |
| 7 | -- the same load-bearing constraint the issues table has, and the two together are what |
| 8 | -- stops an issue and a pull request ever answering to the same URL. |
| 9 | -- |
| 10 | -- **Nothing about where the branches point is stored while the request is open.** The |
| 11 | -- page reads the refs live, so a push to the source branch changes what the request |
| 12 | -- proposes and a force-push is simply the new proposal. `merge_commit` is the exception |
| 13 | -- and the reason: once it has landed, the branches may both be gone, and what actually |
| 14 | -- reached the target is the one fact nothing else can answer. |
| 15 | -- |
| 16 | -- Same repository only — there is no fork column, because there are no forks. |
| 17 | ( |
| 18 | id text primary key, |
| 19 | repo_id text not null references repositories (id) on delete cascade, |
| 20 | number integer not null, |
| 21 | title text not null, |
| 22 | body text not null, |
| 23 | -- `open | merged | closed`, text rather than an integer so a row is readable in a |
| 24 | -- shell, matching `issues.state` and `repositories.visibility`. |
| 25 | state text not null, |
| 26 | author_id text not null references users (id), |
| 27 | source_branch text not null, |
| 28 | target_branch text not null, |
| 29 | created_at integer not null, |
| 30 | updated_at integer not null, |
| 31 | closed_at integer, |
| 32 | merged_at integer, |
| 33 | merge_commit text, |
| 34 | unique (repo_id, number) |
| 35 | ); |
| 36 | |
| 37 | -- The list page filters by state and orders by number descending, which this covers |
| 38 | -- end to end — the shape `issues_repo_state` has, for the same page. |
| 39 | (repo_id, state, number desc); |