-- Runtime repository projection. Each root is a domain collection and each -- row is independently addressable, so PostgreSQL can be promoted from the -- legacy snapshot without exposing a JSON blob as the only source of truth. CREATE TABLE IF NOT EXISTS miragenflow_domain_rows ( root_key TEXT NOT NULL, entity_id TEXT NOT NULL, shape TEXT NOT NULL CHECK (shape IN ('map', 'array', 'scalar')), payload JSONB, updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), PRIMARY KEY (root_key, entity_id) ); CREATE INDEX IF NOT EXISTS miragenflow_domain_rows_updated_idx ON miragenflow_domain_rows(updated_at DESC);