OXYGENHUB
◆ v0.4.1 oxygenhub / crates / hub / migrations / 0046_coverage.sql
1.8 KiB · SQL · last changed Coverage page: charts and a livelier layout 1 month ago source blame history raw
554ccacf Andy McCall ↶ 1
-- Coverage reports from OxygenFlow jobs (oxygenhub#113): a job's artifact
2
-- named `coverage` (LCOV) is parsed when uploaded. The totals and each
3
-- file's counts are kept here; the per-line counts stay in the artifact's
4
-- blob and are read again for the file view.
5
CREATE TABLE coverage_reports (
6
    id               INTEGER PRIMARY KEY,
7
    repo_id          INTEGER NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
8
    run_id           INTEGER NOT NULL REFERENCES flow_runs(id) ON DELETE CASCADE,
9
    job_id           INTEGER NOT NULL UNIQUE,
10
    job              TEXT NOT NULL,
11
    run_number       INTEGER NOT NULL,
12
    bookmark         TEXT NOT NULL,
13
    state            TEXT NOT NULL,
14
    heads            TEXT NOT NULL,
15
    blob             TEXT NOT NULL,
16
    format           TEXT NOT NULL,
17
    lines_found      INTEGER NOT NULL,
18
    lines_hit        INTEGER NOT NULL,
19
    functions_found  INTEGER NOT NULL,
20
    functions_hit    INTEGER NOT NULL,
21
    branches_found   INTEGER NOT NULL,
22
    branches_hit     INTEGER NOT NULL,
c987c865 Andy McCall ↶ 23
    -- Every run of every instrumented line, added up: hits per line.
24
    hits             INTEGER NOT NULL DEFAULT 0,
554ccacf Andy McCall ↶ 25
    files            INTEGER NOT NULL,
26
    -- Files the report named that are not in the run's state.
27
    dropped          INTEGER NOT NULL,
28
    created_ms       INTEGER NOT NULL
29
);
30
CREATE INDEX coverage_reports_bookmark ON coverage_reports (repo_id, bookmark, created_ms);
31
CREATE TABLE coverage_files (
32
    report_id        INTEGER NOT NULL REFERENCES coverage_reports(id) ON DELETE CASCADE,
33
    path             TEXT NOT NULL,
34
    lines_found      INTEGER NOT NULL,
35
    lines_hit        INTEGER NOT NULL,
36
    functions_found  INTEGER NOT NULL,
37
    functions_hit    INTEGER NOT NULL,
38
    branches_found   INTEGER NOT NULL,
39
    branches_hit     INTEGER NOT NULL,
40
    PRIMARY KEY (report_id, path)
41
);