Skip to content

[Data integrity] Make Flyway the sole production ETL schema-mutation authority #183

Description

@seonghobae

Buyer / migration-safety gap

Protected develop@622e5e6c3d534f230c390f10e3832efadfc01825 enables both Flyway migration management and Hibernate automatic schema mutation in the deployable ETL service:

spring:
  flyway:
    baseline-on-migrate: ${FLYWAY_BASELINE_ON_MIGRATE:false}
    baseline-version: 0
    clean-disabled: true
    validate-migration-naming: true
  jpa:
    hibernate:
      ddl-auto: update

The active durable-job work already depends on ordered, reviewed Flyway migrations and explicit rollback/forward-recovery evidence. A second runtime DDL authority (ddl-auto: update) makes acquisition-grade schema provenance ambiguous even if it currently happens to find no mapped entity requiring a mutation.

Spring Boot's maintained database-initialization guidance recommends a single mechanism for schema generation and states that when using a higher-level migration tool such as Flyway or Liquibase, it should be used alone to create/initialize the schema. ddl-auto values include none, validate, update, create, and create-drop; non-embedded databases with a schema manager otherwise default to none when not explicitly overridden.

Primary implementation reference to reverify at mutation time: Spring Boot Database Initialization documentation (docs.spring.io/spring-boot/how-to/data-initialization.html).

RCA

  • Immediate cause: deployable ETL configuration explicitly forces Hibernate ddl-auto: update while also enabling Flyway.
  • Technical root cause: database schema authority is split between versioned migration artifacts and runtime ORM introspection/mutation.
  • Systemic/control cause: the repository has strong per-migration tests but no startup/configuration invariant saying protected schema changes may occur only through reviewed migration paths.
  • Detection failure: current source contains no obvious @Entity production type, which can make ddl-auto:update appear inert and allow the unsafe authority to persist unnoticed. Inert today is not a valid schema-governance contract for a future entity addition.

Distinct remedies / feasibility

Preferred — Flyway-only mutation, optional Hibernate validation

  • make Flyway the only production schema-mutation authority;
  • set Hibernate DDL behavior to none or, only if entity-to-schema validation is actually useful and proven against the current non-JPA/JDBC architecture, validate;
  • add a deterministic contract test rejecting update, create, and create-drop in deployable profiles;
  • preserve test-only isolated schema creation only where a test profile explicitly owns it and cannot reach production data;
  • update migration/rollback/Architecture/TRD/Test Strategy documentation accordingly.

Alternative — remove unused JPA schema-generation configuration/dependency surface

If source inventory proves the ETL service does not use JPA entities at all, remove the unused JPA schema-generation configuration (and eventually unused JPA dependency if complete source/runtime verification supports it). This can reduce attack/configuration surface, but must not be mixed into the first authority repair unless dependency removal is independently verified.

Reject

  • keeping update because current mapped-entity count appears zero;
  • allowing Hibernate to create missing tables while Flyway owns later migrations;
  • adding broad baseline-on-migrate=true to hide drift;
  • weakening migration validation or using ORM mutation as rollback;
  • choosing validate without proving it is compatible with the JDBC-owned schema and does not create a false requirement for ORM mappings.

Current implementation classification

planned / known_gap. Before source mutation, recheck current active ETL application-config ownership and durable migration branches. The first TDD slice should be configuration-authority-only, not a broad JPA refactor.

Acceptance

  1. fail-first test proves protected deployable config currently permits Hibernate update;
  2. production/deployable profiles cannot run Hibernate automatic schema mutation (update, create, create-drop);
  3. Flyway remains the sole production schema-changing startup mechanism;
  4. every owned schema change continues to require versioned migration, migration test, rollout/rollback or forward-recovery evidence, and exact PostgreSQL rehearsal where material;
  5. tests prevent a future entity/config change from silently re-enabling runtime DDL mutation;
  6. clean bootstrap, existing-volume upgrade and active durable-job migrations remain compatible;
  7. FLYWAY_BASELINE_ON_MIGRATE remains fail-closed by default and is not used to paper over unmanaged drift;
  8. canonical TRD/Architecture/ADR/Data Model/Test Strategy/Migration/Traceability identifies one schema authority and distinguishes bootstrap compatibility SQL from versioned service migrations;
  9. exact-source CI/security/non-vacuous coverage/review gates pass before protected integration.

Relationship: #150/#155 own legacy bootstrap retirement; #143#148 own durable-job migration stack; #159 owns canonical architecture/data/migration traceability; #165 owns release/provenance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: accessibilityAccessibility and assistive-technology supportarea: authAuthentication, authorization, identity, or tenant isolationarea: ci-cdCI, GitHub Actions, checks, release, or supply chainarea: dependenciesDependency or lockfile maintenancemaintenancepriority: mediumNormal-priority or P2 workstatus: triagedOpen issue has an organization taxonomy assignmenttype: featureNew or expanded product capability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions