OXYGENHUB
# 42a0ba4bac4e oxygenhub / crates / hub / migrations / 0007_releases.sql
1.2 KiB · SQL · last changed Milestone 0.6: releases, Git mirror, code search, anchored API comments 1 month ago source blame history raw
1
-- Releases attach notes and assets to tags (hub spec §9). Tags themselves
2
-- live in the repository; assets are content addressed under <data>/assets.
3
4
CREATE TABLE releases (
5
    id          INTEGER PRIMARY KEY,
6
    repo_id     INTEGER NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
7
    tag         TEXT NOT NULL,
8
    title       TEXT NOT NULL,
9
    notes       TEXT NOT NULL DEFAULT '',
10
    prerelease  INTEGER NOT NULL DEFAULT 0,
11
    author_id   INTEGER REFERENCES accounts(id) ON DELETE SET NULL,
12
    author      TEXT NOT NULL DEFAULT '',
13
    created_ms  INTEGER NOT NULL,
14
    UNIQUE (repo_id, tag)
15
);
16
17
CREATE TABLE release_assets (
18
    id           INTEGER PRIMARY KEY,
19
    release_id   INTEGER NOT NULL REFERENCES releases(id) ON DELETE CASCADE,
20
    name         TEXT NOT NULL,
21
    size         INTEGER NOT NULL,
22
    hash         TEXT NOT NULL,
23
    content_type TEXT NOT NULL DEFAULT 'application/octet-stream',
24
    downloads    INTEGER NOT NULL DEFAULT 0,
25
    created_ms   INTEGER NOT NULL,
26
    UNIQUE (release_id, name)
27
);
28
29
-- Git mirror settings per repository (hub spec §14).
30
ALTER TABLE repositories ADD COLUMN git_mirror INTEGER NOT NULL DEFAULT 0;
31
ALTER TABLE repositories ADD COLUMN git_mirror_state TEXT NOT NULL DEFAULT '';