internal/store/migrations/0028_deps.up.sql
33 lines · 1475 bytes
1-- Dependency update checks: an opt-in per-repo sweep that compares the
2-- manifests on the default branch against upstream registries and reports
3-- what is behind in an issue. Opt-in because checking a private repo tells
4-- a public registry what it depends on.
5CREATE TABLE dep_checks (
6 repo_id INTEGER PRIMARY KEY REFERENCES repos(id) ON DELETE CASCADE,
7 last_check TEXT NOT NULL DEFAULT '',
8 last_error TEXT NOT NULL DEFAULT '',
9 issue_number INTEGER NOT NULL DEFAULT 0
10);
11
12-- What each repo was last told about, so a repo that stays behind is
13-- reported once rather than every sweep.
14CREATE TABLE dep_reports (
15 repo_id INTEGER NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
16 ecosystem TEXT NOT NULL,
17 name TEXT NOT NULL,
18 current TEXT NOT NULL,
19 latest TEXT NOT NULL,
20 PRIMARY KEY (repo_id, ecosystem, name)
21);
22
23-- The account dependency issues are authored by. Keyless and mailless: it
24-- authors, it never authenticates.
25--
26-- The name was not reserved before this migration, so an instance upgrading
27-- from v1.0.x may already have a user or an org holding it. Claim it only if
28-- it is free: a daemon that will not start is a far worse outcome than a
29-- dependency check that reports why it cannot open an issue.
30INSERT INTO users (username, is_admin)
31SELECT 'gitbay-bot', 0
32WHERE NOT EXISTS (SELECT 1 FROM users WHERE username = 'gitbay-bot')
33 AND NOT EXISTS (SELECT 1 FROM orgs WHERE name = 'gitbay-bot');