1 contributor
57 lines | 2.214kb

Table: host_aliases

Stores aliases for canonical hosts. Aliases are retained after retirement for audit and collision prevention.

Columns

Column Type Null Default Notes
alias_name TEXT no none Alias DNS name or short alias.
host_fqdn TEXT no none Target host. References hosts(fqdn).
alias_kind TEXT no 'declared' declared, derived, or derived-vhost.
status TEXT no 'active' Alias lifecycle state.
is_dns_published INTEGER no 1 Whether this alias should appear in generated DNS exports.
created_at TEXT no none ISO UTC creation timestamp.
retired_at TEXT yes NULL ISO UTC retirement timestamp.
notes TEXT no '' Operator notes.

Keys And Indexes

  • Primary key: (alias_name, host_fqdn)
  • Unique partial index: idx_host_aliases_active_name on alias_name where status = 'active'
  • Lookup index: idx_host_aliases_host_status on (host_fqdn, status)

Relationships

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

Rules

  • A retired alias is not deleted; status changes to retired and is_dns_published is set to 0.
  • One active alias can point to only one host.
  • Derived short names such as baobab are persisted with alias_kind = 'derived'.
  • Derived vhost short names such as pmx.baobab are persisted with alias_kind = 'derived-vhost'.

Definition

CREATE TABLE IF NOT EXISTS host_aliases (
    alias_name TEXT NOT NULL,
    host_fqdn TEXT NOT NULL,
    alias_kind TEXT NOT NULL DEFAULT 'declared',
    status TEXT NOT NULL DEFAULT 'active',
    is_dns_published INTEGER NOT NULL DEFAULT 1,
    created_at TEXT NOT NULL,
    retired_at TEXT,
    notes TEXT NOT NULL DEFAULT '',
    PRIMARY KEY (alias_name, host_fqdn),
    FOREIGN KEY (host_fqdn) REFERENCES hosts(fqdn) ON UPDATE CASCADE ON DELETE RESTRICT
);

CREATE UNIQUE INDEX IF NOT EXISTS idx_host_aliases_active_name
ON host_aliases(alias_name)
WHERE status = 'active';

CREATE INDEX IF NOT EXISTS idx_host_aliases_host_status
ON host_aliases(host_fqdn, status);