Why Not ddl-auto

ddl-auto Is for Prototypes

spring.jpa.hibernate.ddl-auto=update lets Hibernate change tables to match your entities. It feels convenient, but in production it is dangerous:

  • It never drops or renames columns: renaming title to name creates a new empty column and the old data is stranded.
  • It cannot migrate data (fill a new column, split a table).
  • There is no history: nobody knows which change ran when, or on which server.
  • Several app instances starting together may race to alter the same table.
  • create / create-drop delete all data.

The Right Settings

Environmentddl-autoSchema comes from
Quick experiment / tutorialcreate-drop or updateHibernate
Tests (@DataJpaTest)validate or noneFlyway/Liquibase scripts (same as prod)
Dev, staging, productionvalidateFlyway/Liquibase scripts

Note: validate makes Hibernate check at startup that every mapped table and column exists with a compatible type. A mismatch stops the app with a clear error instead of failing at runtime.

Migration Tools in One Picture

src/main/resources/db/migration/
   V1__create_categories_and_products.sql
   V2__create_users_orders.sql
   V3__add_product_sku.sql            ← new in this release
          │
          ▼  app starts (Flyway runs BEFORE the EntityManagerFactory)
 flyway_schema_history:  1 ✔  2 ✔  3 (pending → run now) ✔
          │
          ▼
 Hibernate starts with ddl-auto=validate → schema matches entities → app is up