internal/store/migrations/0054_snippets.up.sql

4a511e42574ead9c92dc73fd320f296cc4dbea07
gitbay/internal/store/migrations/0054_snippets.up.sql

20 lines · 885 bytes

 1-- Snippets: named text files a user owns and shares by URL, outside any
 2-- repository. public_id is the opaque id in URLs and commands.
 3CREATE TABLE snippets (
 4    id          INTEGER PRIMARY KEY,
 5    public_id   TEXT NOT NULL UNIQUE,
 6    owner_id    INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 7    description TEXT NOT NULL DEFAULT '',
 8    visibility  TEXT NOT NULL CHECK (visibility IN ('public','unlisted','private')),
 9    created_at  TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
10    updated_at  TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
11);
12CREATE INDEX snippets_owner ON snippets(owner_id, id);
13
14CREATE TABLE snippet_files (
15    snippet_id INTEGER NOT NULL REFERENCES snippets(id) ON DELETE CASCADE,
16    name       TEXT NOT NULL,
17    content    BLOB NOT NULL,
18    size       INTEGER NOT NULL,
19    PRIMARY KEY (snippet_id, name)
20);
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form