- inventory: resolve the image reference via ContainerInspect when a moved tag makes ContainerList report the image ID - store: allow reusing a revoked agent's name (partial unique index) and mark the revoked agent's compose/container services removed - web: publish a services event on revoke; no-store on the one-time token page - webauth: reject empty OIDC state; accept the CSRF form token from the body only - agent conn: bound the WebSocket handshake to 30s - hub: log agent_replaced when a connection replaces an older one
52 lines
1.8 KiB
SQL
52 lines
1.8 KiB
SQL
CREATE TABLE master_identity (
|
|
id int PRIMARY KEY CHECK (id = 1),
|
|
private_key bytea NOT NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE agents (
|
|
id bigserial PRIMARY KEY,
|
|
name text NOT NULL,
|
|
token_hash text NOT NULL UNIQUE,
|
|
hostname text NOT NULL DEFAULT '',
|
|
agent_version text NOT NULL DEFAULT '',
|
|
swarm_manager boolean NOT NULL DEFAULT false,
|
|
last_seen_at timestamptz,
|
|
revoked_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
-- A revoked agent's name can be reused by a new agent.
|
|
CREATE UNIQUE INDEX agents_name_active ON agents (name) WHERE revoked_at IS NULL;
|
|
|
|
CREATE TABLE services (
|
|
id bigserial PRIMARY KEY,
|
|
kind text NOT NULL CHECK (kind IN ('compose', 'swarm', 'container')),
|
|
location_key text NOT NULL UNIQUE,
|
|
agent_id bigint REFERENCES agents (id),
|
|
compose_project text NOT NULL DEFAULT '',
|
|
compose_service text NOT NULL DEFAULT '',
|
|
working_dir text NOT NULL DEFAULT '',
|
|
swarm_cluster_id text NOT NULL DEFAULT '',
|
|
swarm_service text NOT NULL DEFAULT '',
|
|
container_name text NOT NULL DEFAULT '',
|
|
image_repo text NOT NULL,
|
|
actual_ref text NOT NULL,
|
|
actual_digest text NOT NULL DEFAULT '',
|
|
status text NOT NULL,
|
|
self boolean NOT NULL DEFAULT false,
|
|
update_mode text NOT NULL DEFAULT 'manual' CHECK (update_mode IN ('manual', 'auto')),
|
|
first_seen_at timestamptz NOT NULL,
|
|
updated_at timestamptz NOT NULL,
|
|
removed_at timestamptz
|
|
);
|
|
|
|
CREATE TABLE sessions (
|
|
id text PRIMARY KEY,
|
|
subject text NOT NULL,
|
|
name text NOT NULL DEFAULT '',
|
|
email text NOT NULL DEFAULT '',
|
|
csrf_token text NOT NULL,
|
|
expires_at timestamptz NOT NULL
|
|
);
|