Database Migrations with Liquibase
Generated artifact. Do not edit manually.
Generated by:
scripts/build_compendia.pyRegenerate with:python3 scripts/build_compendia.py --compendium dev-handbook --web-and-texSource of truth:docs/dev/source/
Language / Sprache: English (EN) · Deutsch (DE) | PDF: English PDF · Deutsches PDF
Compendium: §1 Documentation Guidelines · §2 Landscape JSON Reference · §3 Minimal Schema & Fallback · §4 Authoring Editors · §5 Graph Editor · §6 Flashcard Editor · §7 Node Ordering · §8 Liquibase · §9 Auto-Update (SSE)
8. Database Migrations with Liquibase
The Spring Boot backend enforces spring.jpa.hibernate.ddl-auto=validate: Hibernate validates JPA entities against the live schema on startup, while Liquibase exclusively owns every schema creation and migration.
8.1. Changelog Layout and Four-Step Migration Workflow
- Master changelog:
backend/src/main/resources/db/changelog/db.changelog-master.yamlincludes ordered versioned files underbackend/src/main/resources/db/changelog/changes/(starting from001-initial-schema.yaml, which usespreConditionswithonFail: MARK_RANso existing pre-Liquibase databases adopt tracking cleanly viaDATABASECHANGELOG). - Four-step workflow for schema changes:
- Update the JPA
@Entityclass inbackend/src/main/java/com/skillpilot/backend/domain/. - Add a new numbered YAML file
NNN-short-description.yamlunderdb/changelog/changes/with a unique(id, author)changeset and explicit types/constraints. - Append an
includeentry todb.changelog-master.yaml. - Start the backend (
./gradlew bootRunor./gradlew test) so Liquibase applies the migration and Hibernatevalidateconfirms exact JPA-to-SQL parity. - Immutability rule: Never edit an already committed and executed changeset (Liquibase checksum validation will fail startup); always append a new corrective changeset instead.