Liquibase changelogs not packaged in tracker-server.jar: build from source

Smashers0904 days ago

Good afternoon,

Background

I follow the documented server build steps at https://www.traccar.org/build/ within a recently created CICD setup:

To build the server binary file (JAR) use following command:
./gradlew assemble
It will automatically download all dependencies and generate tracker-server.jar in the target subfolder. Now you can just replace the file in your Traccar installation and restart the service for changes to take affect."

Issue / Cause

I encountered a database error due to a missing expected database column. On inspection this was added in the latest changelog changelog-6.6.xml.

Investigating further, I found that the Gradle-generated tracker-server.jar file does not include schema changelogs:

unzip -l tracker-server.jar | grep changelog
(no results)

This explains why the latest changeset was not implemented.

Question

I would like to confirm whether:

  1. The build-from-source docs need updating with an additional step
  2. Perhaps /schema folder should be relocated to be included in the final .jar by Gradle, or the /schema folder should be referenced in build.gradle
  3. This is not an issue - I am missing something. Happy to share CICD build steps if this is suspected.

Many thanks

Anton Tananaev4 days ago

Schema files are external and it's expected that they are not included in the JAR.

Smashers0904 days ago

Thank you for the clarification. Reflecting, I can understand why keeping schema files external is intentional, and managing database migrations separately makes sense to avoid accidental changes without backup.

I wonder if it might be beneficial to add a brief note in the Build from source documentation about handling database schema updates. This could help users who might not be aware additional steps may be required when updating from source to ensure the database state matches the server state.

--

For future readers, one solution is to:

  1. Copy the /schema files to a new directory (e.g., /opt/traccar/latest-schema) to prepare for a manual migration. (Part of CI/CD build steps)
  2. Compare the current /schema folder with /latest-schema and notify the user of any differences. If changes are detected, prompt for confirmation that a database backup has been taken; otherwise, exit without action. (shell script)
  3. Once confirmed, stop the Traccar service, replace the contents of /schema with /latest-schema, then start Traccar. (same shell script)
Anton Tananaev4 days ago

It's kind of there:

Make sure you have a compatible version of Traccar installed.

But also you shouldn't use master unless you absolutely know what you're doing. That's because you can get your server into a state where you would have to make database migration manually. It's covered here:

https://www.traccar.org/source-code/

If you decide to use source code, it is recommended to use the latest tag instead of a master branch.