# ADR-031: moduleToDbSchema() for schema updates, not Value.Patch ## Status Accepted ## Context When a graph type Module changes, the stored schema in `node_types.schema` must be updated. This could be done by patching the stored schema with `Value.Patch` or by re-running `moduleToDbSchema()` on the full Module. ## Decision Re-run `moduleToDbSchema()` on the updated Module. Patch-based schema update (`Value.Patch`) is unreliable for `Type.Ref`/`$defs` changes — the diff is structural, not semantic, and may not capture `$defs` reorganization correctly. `moduleToDbSchema()` is more reliable because it always produces a fresh, complete projection. Patch-based schema update is an optimization for later. ## Consequences - Schema updates always go through `moduleToDbSchema()` - The full Module must be available at migration time - No risk of partial/partially-correct patches from `Value.Diff` - Patch-based update can be added as an optimization if needed ## References - [schema-evolution.md](../schema-evolution.md)