OXYGENHUB
◆ main spectra / crates / spectra-core / migrations / 0002_principals.sql
1.0 KiB · SQL · last changed Identities instead of tokens: init, owned agents as delegates, verified replay of identities, request authentication, one writer (#4) 2 days ago source blame history raw
1
-- Projections of who is who (spec §8): identities the ledger knows, by
2
-- role, and agents with their owner and delegation.
3
CREATE TABLE identities (
4
    key       TEXT PRIMARY KEY,           -- KeyId, hex
5
    role      TEXT NOT NULL,              -- owner | instance | agent
6
    name      TEXT NOT NULL,
7
    identity  BLOB NOT NULL,              -- the encoded identity object
8
    previous  TEXT,                       -- the identity it succeeds
9
    current   INTEGER NOT NULL DEFAULT 1, -- 0 once succeeded
10
    seq       INTEGER NOT NULL
11
);
12
13
CREATE TABLE agents (
14
    name         TEXT PRIMARY KEY,
15
    key          TEXT NOT NULL UNIQUE,
16
    owner        TEXT NOT NULL,           -- the owner's KeyId when added
17
    owner_name   TEXT NOT NULL,
18
    kind         TEXT NOT NULL,
19
    project      TEXT NOT NULL,
20
    home         TEXT NOT NULL,
21
    uid          INTEGER,
22
    learn_uid    INTEGER NOT NULL DEFAULT 0,
23
    scopes       TEXT NOT NULL,
24
    created_ms   INTEGER NOT NULL,
25
    disabled_ms  INTEGER,
26
    seq          INTEGER NOT NULL
27
);