Upgrades and migrations
An upgrade replaces the coordinator binary or image and applies any new database migrations. Migrations only go forward, so the backup you take before an upgrade is your only way back.
Before you upgrade
Section titled “Before you upgrade”No release has been published and the repository has no version tags yet. Until the first release, you upgrade by building a newer commit of main.
-
Read the changelog.
CHANGELOG.mdfollows Keep a Changelog. Every change a user can see is listed underUnreleased. Look for lines under Changed that ask you to do something, such as setting a new variable. -
Take a backup. See Backups.
-
Record the audit chain head. Run
audit verifyand keep the last hash somewhere other than the database:Terminal window docker compose -f deploy/docker-compose.yml \run --rm --no-deps -T server audit verifyaudit chain ok: 1234 rows, head <hash>After the upgrade, run it again. The chain must still verify, and the row count must not be lower. See Security hardening.
-
Upgrade
zttoo. Buildztfrom the same commit as the coordinator. No compatibility table betweenztand coordinator versions exists yet.
How migrations run
Section titled “How migrations run”The coordinator uses goose v3. The SQL files in server/migrations are compiled into the binary, so a binary always carries the migrations it needs. goose records the applied versions in its own table, goose_db_version.
There are two ways to apply them:
| Command | When it migrates |
|---|---|
zentri-server migrate up |
Applies every pending migration, then exits. |
zentri-server serve |
Applies every pending migration before it starts serving. --no-migrate skips this. |
Both connect with ZENTRI_MIGRATE_DATABASE_URL, or with ZENTRI_DATABASE_URL when that is unset. Point ZENTRI_MIGRATE_DATABASE_URL at the role that owns the tables. ZENTRI_DATABASE_URL must be set even for migrate up, because the command checks it first.
A Postgres session lock keeps two processes from migrating at once.
Each applied file logs one line, and migrate up ends with a summary:
{"time":"...","level":"INFO","msg":"applied migration","version":10,"file":"00010_slack.sql","duration":12345678}{"time":"...","level":"INFO","msg":"migrations up to date"}The migration numbers have a gap: there is no 00007. 00010_slack.sql was numbered 7 until the model router and skill level migrations took 8 and 9.
Rules the migrations follow
Section titled “Rules the migrations follow”- They are forward-only in production. Each file has a
Downsection for development only. The server has nomigrate downcommand. - A shipped migration is never edited. A fix is a new migration.
- Each migration grants the coordinator role only what it needs. See Requirements and sizing.
Upgrade with Docker Compose
Section titled “Upgrade with Docker Compose”-
Get the new code:
Terminal window git pull -
Rebuild and restart:
Terminal window docker compose -f deploy/docker-compose.yml up --build -dCompose rebuilds the image, runs
migrateas the owner, and recreatesserverwhenmigrateexits with 0. If you use a second Compose file, name it too. -
Check the result:
Terminal window docker compose -f deploy/docker-compose.yml logs migratecurl -fsS http://127.0.0.1:8080/readyzzt doctorThe
migratelog ends withmigrations up to date.zt doctorprints the coordinator version on itstokenline.
The coordinator stops taking new connections on SIGTERM and gives requests in flight up to 10 seconds to finish. Compose runs one server, so expect a short outage while it is replaced.
Upgrade with Helm
Section titled “Upgrade with Helm”-
Back up the database. See Backups.
-
Upgrade the release to the new image:
Terminal window helm upgrade zentri deploy/helm/zentri --namespace zentri --reuse-values \--set image.tag=<new version> --waitThe chart replaces the one coordinator pod with the
Recreatestrategy. The new pod’smigrateinit container applies the new migrations as the owner, then the coordinator starts with--no-migrate. Expect a short outage. -
Check the result:
Terminal window kubectl -n zentri logs deploy/zentri -c migratezt doctorThe
migratelog ends withmigrations up to date.
If a migration fails, the init container fails and the old pod is already gone. Read the migrate log, fix the cause, and the pod retries on its own. See Kubernetes.
Upgrade a binary install
Section titled “Upgrade a binary install”Apply the migrations as the owner, then start the new binary with --no-migrate. In production, keep the URLs in an environment file or your service manager, not in your shell history.
ZENTRI_DATABASE_URL='postgres://zentri_coordinator:<password>@db.internal:5432/zentri' \ZENTRI_MIGRATE_DATABASE_URL='postgres://zentri:<owner password>@db.internal:5432/zentri' \zentri-server migrate upzentri-server serve --no-migratezentri-server version prints the version, the commit and the build date of a binary.
After changing the embedding model
Section titled “After changing the embedding model”Matching compares vectors of one model only. When you change ZENTRI_EMBEDDER or ZENTRI_EMBED_MODEL, embed the stored intents again once:
zentri-server intents reembed --allWithout --all, the command embeds only intents that have no vector yet. The coordinator also does that on its own every --reembed-interval (1 minute by default).
Roll back
Section titled “Roll back”You cannot undo a migration with Zentri’s tools. To go back:
- Stop the coordinator.
- Restore the backup you took before the upgrade.
- Start the build you ran before.
Everything written after the backup is lost.
Limitations
Section titled “Limitations”- No published releases, images or version tags exist yet.
- There is no
migrate downand nomigrate statuscommand. - No compatibility rules between
ztand coordinator versions are written down yet. - Compose runs one server, so an upgrade has a short outage.