Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Database Migrations

An Engineer Left `ddl-auto=update` in Staging. Production Ended Up With Two Columns Instead of One.

By Freedom251 Team · · 4 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

spring.jpa.hibernate.ddl-auto=update can change a database schema at application startup, but the setting alone does not explain why production has two columns where the team expected one. Hibernate documents that update exports schema elements it considers missing and alters incorrect column types; it does not identify what happened in this incident. First compare the live database catalog with the exact deployed entity mappings, naming strategy, migration history, and startup DDL. Preserve both columns and their data until you know which is authoritative.

What ddl-auto=update does—and what it does not prove

Spring Boot exposes Hibernate’s schema-generation behavior through spring.jpa.hibernate.ddl-auto. Its documented values are none, validate, update, create, and create-drop. The default depends on the environment: Spring Boot documents create-drop for an embedded database when no Flyway or Liquibase schema manager is detected, and none otherwise. It does not document update as the default for production databases. See Spring Boot’s database initialization guidance.

As an Amazon Associate I earn from qualifying purchases.

Hibernate’s current configuration documentation describes update as exporting missing schema elements and altering incorrect column types. In effect, Hibernate infers schema differences from its mappings and may modify the database when it initializes. That description does not establish which SQL ran against this production database, or why two columns exist. The database, dialect, Hibernate version, mappings, and deployment history all matter. See Hibernate’s automatic schema export documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A mapping rename, a changed physical naming strategy, different schema state between environments, multiple application versions starting against the same database, or independently managed DDL are all possibilities to investigate—not conclusions that follow from the title. Hibernate’s behavior is documented; the cause of this duplicate-column incident is not established without incident-specific evidence.

How to diagnose the two columns safely

  1. Pause further automatic schema changes. Disable schema mutation for the affected production profile while preserving relevant logs and taking a recoverable backup or snapshot under your team’s operational procedures.
  2. Inspect the live catalog. Identify the database, schema, table, and both column names. Record types, nullability, defaults, constraints, indexes, and the contents of each column. The names alone do not establish which one is correct.
  3. Compare the deployed mapping. Review the exact entity annotations or XML, the physical naming strategy, and the Spring Boot and Hibernate versions in the build that ran against production. Compare these with the actual schema and with the staging configuration.
  4. Trace when the schema changed. Review migration history, deployment order, and startup SQL or Hibernate logs. Establish whether the columns appeared together or at different times, and determine which application versions could have started against the database.
  5. Determine which data is authoritative. Trace application reads and writes and inspect both columns’ data before choosing a canonical column. If data must be merged or copied, make it a reviewed, tested migration with a recovery plan; do not drop a column based only on its name.
  6. Apply a controlled repair. Once the intended schema and data handling are clear, use a reviewed migration to reconcile the columns. Test it against representative data and verify the resulting schema and application behavior before and after deployment.

Collect the mapping, naming strategy, framework and ORM versions, database and schema, migration records, deployment sequence, startup DDL, and resulting column definitions before attributing the event to Hibernate or to a particular release.

Prevent another startup-time schema surprise

Hibernate’s ORM User Guide recommends incremental migration scripts for production, noting: “Although the automatic schema generation is very useful for testing and prototyping purposes, in a production environment, it’s much more flexible to manage the schema using incremental migration scripts.” Read the Hibernate schema-generation guidance.

Set Hibernate to a non-mutating mode in deployed profiles. Use validate if startup should check mappings against the existing schema without applying schema changes, or none if Hibernate should take no schema-generation action. Confirm exact behavior with the versions and environment used by your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Spring Boot identifies Flyway and Liquibase as higher-level migration tools and advises using a single mechanism to create and initialize the schema when one is selected. Avoid having Hibernate and a migration tool compete to manage the same schema. See Spring Boot’s database initialization guidance.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing a migration approach

Flyway and Liquibase are both named by Spring Boot as migration-tool integrations; the documentation here does not establish that one is universally better. Choose based on how the tool fits your database and deployment practices, rather than assuming it will make any DDL change safe by itself.

  • Check that the tool supports the database and SQL dialect you use.
  • Decide how changes will be authored, reviewed, ordered, and recorded in version control.
  • Plan deployment sequencing, application compatibility, recovery, and rollback for your environment.
  • Confirm how migrations run in CI/CD and how the team detects schema drift.

Flyway’s migration concepts documentation describes migration scripts for DDL operations such as CREATE, ALTER, and DROP. That establishes a capability, not a guarantee that a particular migration is safe or reversible. See Flyway migration concepts.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Database MigrationsFlywayHibernateLiquibaseproduction databasesSpring Boot

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.