OXYGENHUB
◆ proposal-list-fast oxygenhub / crates / hub / migrations / 0001_repositories.sql
1014 B · SQL · last changed Milestone 0.1: browse 1 month ago source blame history raw
d23464c0 Andy McCall ↶ 1
-- Hub state that Oxygen has no object for (hub spec §1.4). History,
2
-- references, signatures and policy live in each repository's own store.
3
4
CREATE TABLE repositories (
5
    id               INTEGER PRIMARY KEY,
6
    owner            TEXT NOT NULL,
7
    name             TEXT NOT NULL,
8
    description      TEXT NOT NULL DEFAULT '',
9
    default_bookmark TEXT NOT NULL DEFAULT 'main',
10
    visibility       TEXT NOT NULL DEFAULT 'public' CHECK (visibility IN ('public', 'internal', 'private')),
11
    created_ms       INTEGER NOT NULL,
12
    updated_ms       INTEGER NOT NULL,
13
    UNIQUE (owner, name)
14
);
15
16
-- Every reference update the protocol server accepted or refused (§6.12).
17
CREATE TABLE pushes (
18
    id         INTEGER PRIMARY KEY,
19
    repo_id    INTEGER NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
20
    at_ms      INTEGER NOT NULL,
21
    reference  TEXT NOT NULL,
22
    ok         INTEGER NOT NULL,
23
    reason     TEXT NOT NULL DEFAULT ''
24
);
25
CREATE INDEX pushes_by_repo ON pushes (repo_id, at_ms DESC);