Teammates uses [Liquibase](https://docs.liquibase.com/start/home.html), a database schema change management tool. Whenever a schema change is needed, contributors should add or generate a new changelog so the application code and database schema remain in sync.
Liquibase is made available using the gradle plugin, providing liquibase functions as tasks. Try gradle tasks | grep "liquibase" to see all the tasks available. In teammates, change logs (more in the next section) are written in XML.
Amend the liquibaseDbUrl, liquibaseUsername and liquibasePassword in gradle.properties to allow the Liquibase plugin to connect your database.
A change log is a file that contains a series of change sets (analagous to a transaction) which applies change types (actions). You can refer to this page on liquibase on the types of change types that can be used.
Activities in Gradle are a way of specifying different variables provided by gradle to the Liquibase plugin. The argument runList provided by -pRunList=<activity_name> e.g ./gradlew liquibaseDiffChangelog -PrunList=diffMain is used to specify which activity to be used for the Liquibase command. In this case the liquibaseDiffChangelog command is run using the diffMain activity.
Here is a brief description of the activities defined for Liquibase
runList is not defined.hibernate.cfg.xml) as the reference against the live database to generate a diff changelog. No snapshot file or schemaMode=migrate server run is needed../gradlew liquibaseUpdate -PrunList=main to apply all existing migrations to your local database../gradlew serverRun to verify the current schema passes Hibernate validation../gradlew liquibaseDiffChangelog -PrunList=diffMain -PmigrationName=<descriptive-name> to generate a changelog (e.g. -PmigrationName=add-feedback-indexes). This compares the Hibernate entity model (the desired schema) against the live database (the current state) and produces changesets that bring the database up to match the model. Review the generated changelog manually before committing — auto-diff output can be noisy or incorrect depending on type mappings.src/main/resources/db/changelog/migrations are auto-included by the root changelog via includeAll, so no manual root changelog edits are needed.Hibernate validates the database schema against your entity model on every startup. If they do not match, the server will fail to start with a schema-validation error. This usually means you pulled changes that include new or updated migrations but have not applied them yet.
Recovery steps:
./gradlew liquibaseUpdate -PrunList=main to apply missing migrations../gradlew serverRun to confirm validation passes.If that does not resolve it:
docker compose down.rm -rf postgres-data).docker compose up -d../gradlew liquibaseUpdate -PrunList=main to rebuild the schema from changelogs../gradlew serverRun to confirm validation passes.