-- A1 — routes table (P3-owned). Not present in 0001_init.sql: the RouteStore port is a -- Redis-like live routing table (INV7 — NOT source of truth). This Postgres adapter needs a -- durable backing for it. Postgres has no per-key TTL, so we store an explicit `expires_at` -- and treat `expires_at <= now()` as ABSENT (fail-closed, INV7); expired rows are lazily -- DELETEd on access. This mirrors `store/memory.ts` memRouteStore() semantics exactly. -- -- No FK to hosts(host_id): routes are an ephemeral location cache keyed by host_id, decoupled -- from the ownership source of truth (matches memory.ts, where routes live independently). CREATE TABLE IF NOT EXISTS routes ( host_id uuid PRIMARY KEY, relay_node_id text NOT NULL, updated_at timestamptz NOT NULL, expires_at timestamptz NOT NULL ); CREATE INDEX IF NOT EXISTS routes_node_idx ON routes(relay_node_id);