g1t/services/work/migrations/0001_init.sql
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Issues and pull requests replace intents and attempts | 1 | -- Issues, pull requests, comments and sessions. |
| 2 | -- Every timestamp is RFC 3339 UTC text. | |
| 3 | ||
| 4 | -- Issues and pull requests share one sequence of numbers per repository. | |
| 5 | CREATE TABLE counters ( | |
| 6 | repo_id TEXT PRIMARY KEY, | |
| 7 | last INTEGER NOT NULL | |
| 8 | ); | |
| 9 | ||
| 10 | CREATE TABLE issues ( | |
| Initial g1t: services, event bus, intents and attempts | 11 | id TEXT PRIMARY KEY, |
| 12 | repo_id TEXT NOT NULL, | |
| 13 | number INTEGER NOT NULL, | |
| 14 | title TEXT NOT NULL, | |
| Issues and pull requests replace intents and attempts | 15 | body TEXT NOT NULL, |
| 16 | -- JSON array of label names. | |
| 17 | labels TEXT NOT NULL DEFAULT '[]', | |
| Initial g1t: services, event bus, intents and attempts | 18 | -- JSON array of commands. |
| 19 | checks TEXT NOT NULL DEFAULT '[]', | |
| Issues and pull requests replace intents and attempts | 20 | state TEXT NOT NULL DEFAULT 'open', |
| 21 | -- Why it was closed: completed or not_planned. | |
| 22 | reason TEXT, | |
| 23 | -- The number of the pull request whose merge closed it. | |
| 24 | resolved_by INTEGER, | |
| Initial g1t: services, event bus, intents and attempts | 25 | author_id TEXT NOT NULL, |
| 26 | author_name TEXT NOT NULL, | |
| Issues and pull requests replace intents and attempts | 27 | created_at TEXT NOT NULL, |
| 28 | updated_at TEXT NOT NULL, | |
| 29 | closed_at TEXT, | |
| Initial g1t: services, event bus, intents and attempts | 30 | UNIQUE (repo_id, number) |
| 31 | ); | |
| Issues and pull requests replace intents and attempts | 32 | CREATE INDEX issues_by_state ON issues (repo_id, state, number); |
| Initial g1t: services, event bus, intents and attempts | 33 | |
| Issues and pull requests replace intents and attempts | 34 | CREATE TABLE pulls ( |
| Initial g1t: services, event bus, intents and attempts | 35 | id TEXT PRIMARY KEY, |
| 36 | repo_id TEXT NOT NULL, | |
| 37 | number INTEGER NOT NULL, | |
| Issues and pull requests replace intents and attempts | 38 | -- The issue it is for, if any, and that issue's number. |
| 39 | issue_id TEXT REFERENCES issues (id), | |
| 40 | issue_number INTEGER, | |
| 41 | title TEXT NOT NULL, | |
| 42 | body TEXT, | |
| Initial g1t: services, event bus, intents and attempts | 43 | agent TEXT NOT NULL, |
| 44 | runtime TEXT NOT NULL, | |
| Issues and pull requests replace intents and attempts | 45 | status TEXT NOT NULL DEFAULT 'draft', |
| Initial g1t: services, event bus, intents and attempts | 46 | fork_repo_id TEXT NOT NULL UNIQUE, |
| 47 | fork_namespace TEXT NOT NULL, | |
| 48 | fork_name TEXT NOT NULL, | |
| 49 | head_commit TEXT, | |
| Issues and pull requests replace intents and attempts | 50 | -- What the branch pointed to before a merged pull request landed. |
| 51 | merge_base TEXT, | |
| 52 | merged_by TEXT, | |
| 53 | merged_at TEXT, | |
| 54 | -- The pull request merged instead of this one. | |
| 55 | superseded_by INTEGER, | |
| 56 | author_id TEXT NOT NULL, | |
| 57 | author_name TEXT NOT NULL, | |
| 58 | created_at TEXT NOT NULL, | |
| 59 | updated_at TEXT NOT NULL, | |
| 60 | UNIQUE (repo_id, number) | |
| Initial g1t: services, event bus, intents and attempts | 61 | ); |
| Issues and pull requests replace intents and attempts | 62 | CREATE INDEX pulls_by_status ON pulls (repo_id, status, number); |
| 63 | CREATE INDEX pulls_by_issue ON pulls (issue_id); | |
| 64 | CREATE INDEX pulls_by_author ON pulls (author_id, status); | |
| Initial g1t: services, event bus, intents and attempts | 65 | |
| Issues and pull requests replace intents and attempts | 66 | -- On an issue or a pull request: the two share numbers. |
| 67 | CREATE TABLE comments ( | |
| 68 | id TEXT PRIMARY KEY, | |
| 69 | repo_id TEXT NOT NULL, | |
| 70 | number INTEGER NOT NULL, | |
| 71 | author_id TEXT NOT NULL, | |
| 72 | author_name TEXT NOT NULL, | |
| 73 | body TEXT NOT NULL, | |
| 74 | created_at TEXT NOT NULL | |
| 75 | ); | |
| 76 | CREATE INDEX comments_by_subject ON comments (repo_id, number, id); | |
| 77 | ||
| Initial g1t: services, event bus, intents and attempts | 78 | CREATE TABLE session_entries ( |
| Issues and pull requests replace intents and attempts | 79 | pull_id TEXT NOT NULL REFERENCES pulls (id), |
| Initial g1t: services, event bus, intents and attempts | 80 | seq INTEGER NOT NULL, |
| 81 | kind TEXT NOT NULL, | |
| 82 | text TEXT NOT NULL, | |
| 83 | tool TEXT, | |
| 84 | -- The fork's head when the entry was recorded: links reasoning to code. | |
| 85 | "commit" TEXT, | |
| Issues and pull requests replace intents and attempts | 86 | at TEXT NOT NULL, |
| 87 | PRIMARY KEY (pull_id, seq) | |
| Initial g1t: services, event bus, intents and attempts | 88 | ); |