internal/store/migrations/0050_runner_repos.up.sql
19 lines · 890 bytes
1-- A runner key is attached to the repositories it may claim builds for
2-- (#184). runner_seen is rekeyed by key so two runners on one account
3-- are two rows; what it held were heartbeats, so the rows are dropped.
4CREATE TABLE runner_repos (
5 key_id INTEGER NOT NULL REFERENCES ssh_keys(id) ON DELETE CASCADE,
6 repo_id INTEGER NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
7 added_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
8 PRIMARY KEY (key_id, repo_id)
9);
10CREATE INDEX runner_repos_repo ON runner_repos(repo_id);
11
12DROP TABLE runner_seen;
13CREATE TABLE runner_seen (
14 key_id INTEGER PRIMARY KEY REFERENCES ssh_keys(id) ON DELETE CASCADE,
15 user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
16 last_seen TEXT NOT NULL,
17 scope TEXT NOT NULL DEFAULT '',
18 build_id INTEGER REFERENCES builds(id) ON DELETE SET NULL
19);