# ADR-JPA-004 — Flyway is the schema source of truth - Status: Accepted - Date: 2026-08-11 - Design: §31 ## Context Hibernate can create and alter schema from the entity mapping. Flyway can apply versioned scripts. Both cannot own the schema. ## Decision Flyway owns every schema change. Hibernate validates and never mutates: `ddl-auto` is `validate` or `none`, enforced at startup. The runtime database credential holds no DDL privilege, so the rule is enforced by the server as well as by configuration. ## Consequences `ddl-auto=update` fails in a specific and expensive way: it adds but never drops or narrows, so the result is a schema that is neither the previous one nor the one the mappings describe — produced silently, by whichever instance started first, with no record of what it did. Two credentials rather than one is what makes this more than a convention. A configuration rule can be overridden by a property; a role without `CREATE` cannot be overridden by anything the application does. Validation fails closed and never repairs. `repair` rewrites the schema history to match the scripts on disk, which resolves a checksum mismatch by deleting the evidence of which change is missing. The cost is that a schema change requires a migration script and a deployment step. That is the intended cost: it makes schema change reviewable and reversible. ## Enforcement `JpaDangerousConfigurationGuard`; `FlywaySchemaPolicy`; `FlywayValidationGate`; `PostgreSqlRuntimeRoleVerifier`; release gates `flyway-validate` and `runtime-role-no-ddl`.