OXYGENHUB
◆ v0.9.5 oxygenhub / crates / hub / migrations / 0088_flow_skip.sql
2.0 KiB · SQL · last changed Push without starting a run: [skip flow] (closes #284) 15 days ago source blame history raw
1
-- Pushing without a run (oxygenhub#284): `[skip flow]`, `[skip ci]` or
2
-- `[ci skip]` in the newest pushed change's message records a skipped run
3
-- instead of starting jobs. Where a maintainer allows it: `any` bookmark
4
-- (the default), `others` than the default bookmark, or `never`.
5
ALTER TABLE repositories ADD COLUMN flow_skip TEXT NOT NULL DEFAULT 'any';
6
7
-- A skipped run is recorded with status `skipped`. SQLite cannot change a
8
-- CHECK constraint in place, so flow_runs is rebuilt as in 0033 (with
9
-- foreign keys off during migrations, its jobs and reports stay).
10
CREATE TABLE flow_runs_new (
11
    id            INTEGER PRIMARY KEY,
12
    repo_id       INTEGER NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
13
    bookmark      TEXT NOT NULL,
14
    -- The bookmark's state hash (checks are keyed by it) and its heads, joined with '+'.
15
    state         TEXT NOT NULL,
16
    heads         TEXT NOT NULL,
17
    pipeline_hash TEXT NOT NULL DEFAULT '',
18
    status        TEXT NOT NULL CHECK (status IN ('queued', 'running', 'passed', 'failed', 'error', 'cancelled', 'skipped')),
19
    -- Pipeline problems, one per line, for a run in error; why, for a skipped one.
20
    error         TEXT NOT NULL DEFAULT '',
21
    actor         TEXT NOT NULL DEFAULT '',
22
    created_ms    INTEGER NOT NULL,
23
    finished_ms   INTEGER,
24
    number        INTEGER NOT NULL DEFAULT 0,
25
    trigger       TEXT NOT NULL DEFAULT 'push',
26
    priority      TEXT NOT NULL DEFAULT '',
27
    priority_note TEXT NOT NULL DEFAULT ''
28
);
29
INSERT INTO flow_runs_new (id, repo_id, bookmark, state, heads, pipeline_hash, status, error, actor, created_ms, finished_ms, number, trigger, priority, priority_note)
30
    SELECT id, repo_id, bookmark, state, heads, pipeline_hash, status, error, actor, created_ms, finished_ms, number, trigger, priority, priority_note FROM flow_runs;
31
DROP TABLE flow_runs;
32
ALTER TABLE flow_runs_new RENAME TO flow_runs;
33
CREATE INDEX flow_runs_by_repo ON flow_runs (repo_id, id DESC);
34
CREATE UNIQUE INDEX flow_runs_number ON flow_runs (repo_id, number);