OXYGENHUB
◆ v0.9.23 oxygenhub / crates / hub / migrations / 0023_flow_runners.sql
1.5 KiB · SQL · last changed Runners: registration, Admin -> Runners, history, drain/disable/remove 1 month ago source blame history raw
1
-- Runners (hub spec §13.2): registered from the UI with a one-time token,
2
-- or configured with a hub.toml token (tracked here from their first
3
-- claim). A runner signs receipts with one key: bound at registration, or
4
-- on the first signed receipt of a configured runner.
5
CREATE TABLE flow_runners (
6
    id INTEGER PRIMARY KEY,
7
    name TEXT NOT NULL,
8
    token_hash TEXT NOT NULL UNIQUE,
9
    -- 'registered' or 'config'
10
    source TEXT NOT NULL,
11
    key TEXT NOT NULL DEFAULT '',
12
    key_name TEXT NOT NULL DEFAULT '',
13
    arch TEXT NOT NULL DEFAULT '',
14
    os TEXT NOT NULL DEFAULT '',
15
    version TEXT NOT NULL DEFAULT '',
16
    -- comma-separated
17
    labels TEXT NOT NULL DEFAULT '',
18
    max_jobs INTEGER NOT NULL DEFAULT 1,
19
    memory_mib INTEGER,
20
    cpus INTEGER,
21
    -- 'active', 'draining' (finishes its jobs, claims no more) or 'disabled'
22
    state TEXT NOT NULL DEFAULT 'active',
23
    created_ms INTEGER NOT NULL,
24
    created_by TEXT NOT NULL DEFAULT '',
25
    last_seen_ms INTEGER
26
);
27
-- Keys already bound to configured runners move over.
28
INSERT INTO flow_runners (name, token_hash, source, key, key_name, created_ms)
29
    SELECT name, token_hash, 'config', key, name, first_ms FROM flow_runner_keys;
30
CREATE TABLE flow_runner_registrations (
31
    token_hash TEXT PRIMARY KEY,
32
    created_by TEXT NOT NULL,
33
    created_ms INTEGER NOT NULL,
34
    expires_ms INTEGER NOT NULL,
35
    used_ms INTEGER,
36
    runner_id INTEGER
37
);
38
ALTER TABLE flow_jobs ADD COLUMN runner_id INTEGER;
39
CREATE INDEX flow_jobs_runner ON flow_jobs(runner_id);