Context
Problem Statement
HDIM had mixed database migration approaches (Flyway in some services, no migrations in others) creating inconsistency, version control issues, and unsafe schema changes. Needed standardized migration tool with rollback support for production safety.
Options Considered
Option 1: Liquibase for All Services
Description: Standardize on Liquibase 4.29.2 for all database migrations with explicit rollback SQL
Pros:
Cons:
Estimated Effort: 3 weeks migration
Risk Level: Low (well-tested)
Option 2: Keep Flyway (Existing)
Description: Continue using Flyway in services where deployed
Pros:
Cons:
Risk Level: High (no rollback support)
Decision
We chose Option 1 (Liquibase for All Services) because:
Consequences
Positive
Negative
Implementation
Key Principle
Every changeset MUST have explicit rollback SQL - No exceptions
<changeSet id="0001-create-patients-table" author="dev">
<createTable tableName="patients">
<column name="id" type="UUID" primaryKey="true"/>
</createTable>
<rollback>
<dropTable tableName="patients"/>
</rollback>
</changeSet>Migration Pattern
File Structure:
src/main/resources/db/changelog/ ├── 0000-enable-extensions.xml ├── 0001-create-patients-table.xml ├── 0002-add-insurance-table.xml └── db.changelog-master.xml
Naming Convention: NNNN-descriptive-name.xml (4-digit sequential numbers)
Configuration
spring:
liquibase:
enabled: true
change-log: classpath:db/changelog/db.changelog-master.xml
jpa:
hibernate:
ddl-auto: validate # MUST be validate, never create/updateSuccess Criteria
Monitoring & Validation
Metrics
| Metric | Target | Current |
|--------|--------|---------|
| Services using Liquibase | 29/29 | 29/29 ✅ |
| Rollback coverage | 100% | 100% ✅ |
| Failed migrations | 0 | 0 |
Validation Script
backend/scripts/validate-liquibase-rollback.sh
Checks every changeset has explicit rollback
References
Footer
ADR #: 005
Version: 1.0
Status: Active and Validated
Metrics: 100% Rollback Coverage (199/199 changesets)
_Decision Date: Phase 3 (November 2025)_
_Formalized: January 2026_
_Migration Status: Complete (Flyway → Liquibase)_