internal/store/migrations/0008_statuses.up.sql

9bf001e41785e5c85d396154fe8d5cb2da235c14
gitbay/internal/store/migrations/0008_statuses.up.sql history · blame · raw

14 lines · 715 bytes

 1CREATE TABLE commit_statuses (
 2    id          INTEGER PRIMARY KEY,
 3    repo_id     INTEGER NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
 4    commit_sha  TEXT NOT NULL,
 5    context     TEXT NOT NULL,
 6    state       TEXT NOT NULL CHECK (state IN ('pending','success','failure','error')),
 7    description TEXT NOT NULL DEFAULT '',
 8    target_url  TEXT NOT NULL DEFAULT '',
 9    creator_id  INTEGER REFERENCES users(id) ON DELETE SET NULL,
10    created_at  TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
11    updated_at  TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
12    UNIQUE (repo_id, commit_sha, context)
13);
14CREATE INDEX commit_statuses_sha ON commit_statuses(repo_id, commit_sha);