g1t/services/actions/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.
| GitHub Actions on g1t, part two: running workflows | 1 | -- GitHub Actions workflows on g1t: the workflows on each repository's |
| 2 | -- default branch, their runs and jobs, the jobs' logs, and the secrets and | |
| 3 | -- variables they read. Every timestamp is RFC 3339 UTC. | |
| 4 | ||
| 5 | -- Workflows as they are on the default branch: for listing, schedules and | |
| 6 | -- manual runs. Runs for pushes and pull requests read the file at their | |
| 7 | -- own commit. | |
| 8 | CREATE TABLE workflows ( | |
| 9 | id TEXT PRIMARY KEY, | |
| 10 | repo_id TEXT NOT NULL, | |
| 11 | -- owner/name. | |
| 12 | repo TEXT NOT NULL, | |
| 13 | -- .github/workflows/ci.yml | |
| 14 | path TEXT NOT NULL, | |
| 15 | name TEXT NOT NULL, | |
| 16 | source TEXT NOT NULL, | |
| 17 | -- The events that start it, as a JSON array. | |
| 18 | events TEXT NOT NULL, | |
| 19 | -- Its schedules' cron lines, as a JSON array. | |
| 20 | crons TEXT NOT NULL DEFAULT '[]', | |
| 21 | error TEXT, | |
| 22 | -- active or disabled; kept when the file changes. | |
| 23 | state TEXT NOT NULL DEFAULT 'active', | |
| 24 | -- How many runs it has had, for run numbers. | |
| 25 | run_count INTEGER NOT NULL DEFAULT 0, | |
| 26 | updated_at TEXT NOT NULL, | |
| 27 | UNIQUE (repo_id, path) | |
| 28 | ); | |
| 29 | CREATE INDEX workflows_scheduled ON workflows (state, crons); | |
| 30 | ||
| 31 | CREATE TABLE synced ( | |
| 32 | repo_id TEXT PRIMARY KEY, | |
| 33 | at TEXT NOT NULL | |
| 34 | ); | |
| 35 | ||
| 36 | CREATE TABLE runs ( | |
| 37 | id TEXT PRIMARY KEY, | |
| 38 | workflow_id TEXT NOT NULL, | |
| 39 | repo_id TEXT NOT NULL, | |
| 40 | repo TEXT NOT NULL, | |
| 41 | path TEXT NOT NULL, | |
| 42 | name TEXT NOT NULL, | |
| 43 | title TEXT NOT NULL, | |
| 44 | number INTEGER NOT NULL, | |
| 45 | attempt INTEGER NOT NULL DEFAULT 1, | |
| 46 | -- The GitHub event and activity type. | |
| 47 | event TEXT NOT NULL, | |
| 48 | action TEXT, | |
| 49 | git_ref TEXT NOT NULL, | |
| 50 | sha TEXT NOT NULL, | |
| 51 | pull INTEGER, | |
| 52 | -- pending (waiting for its concurrency group), queued, in_progress, completed. | |
| 53 | status TEXT NOT NULL, | |
| 54 | conclusion TEXT, | |
| 55 | -- Why the run could not start, such as a workflow file that does not read. | |
| 56 | error TEXT, | |
| 57 | actor TEXT, | |
| 58 | actor_id TEXT, | |
| 59 | -- The workflow file as of the run's commit. | |
| 60 | source TEXT NOT NULL, | |
| 61 | -- The github context's fields and the event's payload (RunInfo). | |
| 62 | info TEXT NOT NULL, | |
| 63 | -- workflow_dispatch inputs, as JSON. | |
| 64 | inputs TEXT NOT NULL DEFAULT '{}', | |
| 65 | -- 0 for a pull request from outside the workspace: its jobs get no | |
| 66 | -- secrets and no token that can write. | |
| 67 | trusted INTEGER NOT NULL DEFAULT 1, | |
| 68 | concurrency_group TEXT, | |
| 69 | -- What started it, so an event starts each workflow once. | |
| 70 | event_key TEXT NOT NULL, | |
| 71 | created_at TEXT NOT NULL, | |
| 72 | started_at TEXT, | |
| 73 | finished_at TEXT, | |
| 74 | UNIQUE (repo_id, path, event_key) | |
| 75 | ); | |
| 76 | CREATE INDEX runs_by_repo ON runs (repo_id, id); | |
| 77 | CREATE INDEX runs_by_workflow ON runs (workflow_id, id); | |
| 78 | CREATE INDEX runs_by_status ON runs (status); | |
| 79 | CREATE INDEX runs_by_group ON runs (repo_id, concurrency_group, status); | |
| 80 | CREATE INDEX runs_by_sha ON runs (repo_id, sha); | |
| 81 | ||
| 82 | CREATE TABLE jobs ( | |
| 83 | id TEXT PRIMARY KEY, | |
| 84 | run_id TEXT NOT NULL, | |
| 85 | repo_id TEXT NOT NULL, | |
| 86 | -- The workspace, for its limit on jobs running at once. | |
| 87 | namespace TEXT NOT NULL, | |
| 88 | -- Its key under jobs:, and which matrix combination it is (0 without one). | |
| 89 | key TEXT NOT NULL, | |
| 90 | ordinal INTEGER NOT NULL DEFAULT 0, | |
| 91 | name TEXT NOT NULL, | |
| 92 | needs TEXT NOT NULL DEFAULT '[]', | |
| 93 | -- The matrix combination, as JSON; null until it is expanded. | |
| 94 | matrix TEXT, | |
| 95 | -- waiting (for its needs), queued, in_progress, completed. | |
| 96 | status TEXT NOT NULL, | |
| 97 | conclusion TEXT, | |
| 98 | steps TEXT NOT NULL DEFAULT '[]', | |
| 99 | annotations TEXT NOT NULL DEFAULT '[]', | |
| 100 | outputs TEXT NOT NULL DEFAULT '{}', | |
| 101 | reason TEXT, | |
| 102 | token_hash TEXT, | |
| 103 | timeout_minutes INTEGER NOT NULL DEFAULT 60, | |
| 104 | -- continue-on-error: a failure that does not fail the run. | |
| 105 | continue_on_error INTEGER NOT NULL DEFAULT 0, | |
| 106 | -- strategy.max-parallel: how many of its matrix may run at once. | |
| 107 | max_parallel INTEGER, | |
| 108 | -- The last time its sandbox reported anything. | |
| 109 | seen_at TEXT, | |
| 110 | started_at TEXT, | |
| 111 | finished_at TEXT | |
| 112 | ); | |
| 113 | CREATE INDEX jobs_by_run ON jobs (run_id, key, ordinal); | |
| 114 | CREATE INDEX jobs_by_status ON jobs (status, namespace); | |
| 115 | ||
| 116 | CREATE TABLE logs ( | |
| 117 | job_id TEXT NOT NULL, | |
| 118 | seq INTEGER NOT NULL, | |
| 119 | step INTEGER NOT NULL, | |
| 120 | text TEXT NOT NULL, | |
| 121 | PRIMARY KEY (job_id, seq) | |
| 122 | ); | |
| 123 | ||
| 124 | -- Secrets and variables, a repository's or a workspace's. A secret's value | |
| 125 | -- is sealed, bound to its row's id. | |
| 126 | CREATE TABLE settings ( | |
| 127 | id TEXT PRIMARY KEY, | |
| 128 | -- repository or workspace. | |
| 129 | scope TEXT NOT NULL, | |
| 130 | -- The repository's id, or the workspace's slug. | |
| 131 | owner TEXT NOT NULL, | |
| 132 | -- secret or variable. | |
| 133 | kind TEXT NOT NULL, | |
| 134 | name TEXT NOT NULL, | |
| 135 | value TEXT NOT NULL, | |
| 136 | updated_at TEXT NOT NULL, | |
| 137 | UNIQUE (owner, kind, name) | |
| 138 | ); |