1 contributor
35 lines | 1.093kb

Table: host_roles

Stores host roles separately from hosts so the host table does not grow a role-specific column set.

Columns

Column Type Null Default Notes
host_fqdn TEXT no none Target host. References hosts(fqdn).
role TEXT no none Role label, for example proxmox, pbs, storage.
status TEXT no 'active' Role lifecycle state.
created_at TEXT no none ISO UTC creation timestamp.
retired_at TEXT yes NULL ISO UTC retirement timestamp.

Keys And Indexes

  • Primary key: (host_fqdn, role)

Relationships

  • host_fqdn references hosts(fqdn) with ON UPDATE CASCADE ON DELETE RESTRICT

Definition

CREATE TABLE IF NOT EXISTS host_roles (
    host_fqdn TEXT NOT NULL,
    role TEXT NOT NULL,
    status TEXT NOT NULL DEFAULT 'active',
    created_at TEXT NOT NULL,
    retired_at TEXT,
    PRIMARY KEY (host_fqdn, role),
    FOREIGN KEY (host_fqdn) REFERENCES hosts(fqdn) ON UPDATE CASCADE ON DELETE RESTRICT
);