-- What modules exist, and which nodes run them. -- -- novox/hq ADR 0006 gives inventory nodes, modules, assignments and versions. Nodes were built -- first because everything needs to name one; these are the rest, and they are what lets the -- control plane decide what a node runs rather than relay what a person wrote. create table module ( name text primary key, -- The manifest exactly as given: what it provides, requires, claims, needs of the machine, -- and the resources it puts on a node. -- -- Held whole rather than shredded into columns. Every field of it is read together when a -- node is resolved, nothing here queries one part of it, and a manifest that gains a field -- should not need a migration before it can be stored -- the module system is the thing most -- likely to grow (ADR 0009). manifest jsonb not null, version text, registered timestamptz not null default now() ); create table assignment ( node uuid not null references node(id) on delete cascade, module text not null references module(name) on delete restrict, assigned timestamptz not null default now(), primary key (node, module) ); -- Removing a node takes its assignments; removing a module does NOT, and that asymmetry is -- deliberate. A node that is gone cannot be running anything. A module that is still assigned -- somewhere is being run by a machine right now, and deleting the record would leave that machine -- holding something the mesh can no longer describe -- so it is refused until it is unassigned. create index assignment_module on assignment (module);