TEAMMATES uses Liquibase to manage database schema changes. Changelogs are written in XML and live in src/main/resources/db/changelog/migrations/.
The following variables can be configured in gradle.properties. Defaults are pre-configured for local development.
liquibaseDbUrlliquibaseUsernameliquibasePassword./gradlew liquibaseUpdate
gradlew.bat liquibaseUpdate
Run this after pulling changes that include new migration files, or after a fresh database setup.
./gradlew liquibaseUpdate
./gradlew serverRun
gradlew.bat liquibaseUpdate
gradlew.bat serverRun
Make your entity/model changes.
Generate a diff changelog:
./gradlew liquibaseDiffChangelog -PmigrationName=<descriptive-name>
This compares your Hibernate entity model against the live database and produces the necessary changesets. Review and edit the output before committing.
gradlew.bat liquibaseDiffChangelog -PmigrationName=<descriptive-name>
This compares your Hibernate entity model against the live database and produces the necessary changesets. Review and edit the output before committing.
<sql> tag, add a <rollback> block manually.
To roll back the last N changesets:
./gradlew liquibaseRollbackCount -Pcount=<N>
gradlew.bat liquibaseRollbackCount -Pcount=<N>
Note that a single migration file may contain multiple changesets — check the file to determine the correct count.
Hibernate validates the database schema on every startup. If the schema does not match the entity model, the server will fail to start. This usually means new migrations have not been applied yet.
Recovery steps:
./gradlew liquibaseUpdate
./gradlew serverRun
gradlew.bat liquibaseUpdate
gradlew.bat serverRun
docker compose down
rm -rf postgres-data
docker compose up -d
./gradlew liquibaseUpdate
./gradlew serverRun
docker compose down
rm -rf postgres-data
docker compose up -d
gradlew.bat liquibaseUpdate
gradlew.bat serverRun