Upgrades & version pinning
Releases
Section titled “Releases”Releases are cut by release-please
watching main. Conventional commits drive the version bump:
When release-please opens its release PR and it merges, a semver tag
is created (v0.7.2). Release-please explicitly dispatches
docker-publish.yml at that tag to publish :0.7.2, :0.7, :0
and :latest. A tag push can also trigger publication.
Image tags
Section titled “Image tags”The safe upgrade flow
Section titled “The safe upgrade flow”Use a maintenance window. Every API and worker sharing the database must stop before migration, including replicas outside this Compose project. A read-only frontend does not stop background writers. Leave Postgres, Redis and storage running. Never remove data volumes during an upgrade.
-
Read the release notes and pin one published version. Save the same
SCANI_IMAGE_TAGin.env, then export it for every command below:Terminal window export SCANI_IMAGE_TAG=0.56.0 # choose a published releasedocker compose -f docker-compose.prod.yml --profile migrate pull api worker data-provider frontend-app migrateThis includes
scani/api,scani/worker,scani/data-provider,scani/frontend-appandscani/migrate. Record image digests and keep the previous version and configuration. Semver tags are the production default; mutable aliases can change between pulls. -
Drain traffic and jobs, stop all old application processes, then back up. Disable external traffic and any other deployment that could restart old replicas. For this Compose project:
Terminal window docker compose -f docker-compose.prod.yml stop --timeout 60 frontend-app api worker data-providerrunning=$(docker compose -f docker-compose.prod.yml ps --status running --quiet frontend-app api worker data-provider) || exit 1[ -z "$running" ] || { echo "Application services are still running" >&2; exit 1; }Verify other replicas separately. With all writers stopped, take the final full Postgres snapshot. For the bundled database and default database/user names:
Terminal window umask 077docker compose -f docker-compose.prod.yml exec -T postgres \pg_dump -U scani -d scani --format=custom --no-owner > scani-before-upgrade.dumpcp -p .env .env.before-upgradeRequire a successful dump and verify it with
pg_restore --listbefore continuing. Managed databases can use their verified snapshot procedure instead. Preserve encryption material and storage backups. See Backup & restore. -
Apply migrations with the pinned image while old services stay stopped.
Terminal window docker compose -f docker-compose.prod.yml --profile migrate run --rm migrateRequire exit code 0. If stop, backup or migration fails, halt the upgrade. Keep maintenance enabled and application services stopped. Inspect the error; do not start the old images against a partly upgraded database.
-
Start matching new services and verify them before reopening traffic.
Terminal window docker compose -f docker-compose.prod.yml up -d --wait --wait-timeout 180 --no-deps frontend-app api worker data-providercurl --fail http://localhost:8080/api/readyzcurl --fail http://localhost:8080/version.jsondocker compose -f docker-compose.prod.yml logs --tail 100 api workerAdapt the local port to your configuration. Require API readiness, the expected release/commit, and the new worker’s queue registration. Exercise a legacy undo, an account read and a supported sync before ending maintenance. Old API or worker replicas must not rejoin. Nginx
/healthzalone does not prove application readiness. -
If rerunning the installer, confirm the same maintenance prerequisites. The installer uses the pin in
.env. An exported override must match that pin. Existing installations require a full semver pin and this explicit attestation:Terminal window SCANI_UPGRADE_BACKUP_CONFIRMED=1 bash scripts/self-host.shUse the current installer from your chosen release, or download it into the install directory before running it. The confirmation means you already drained all replicas and saved the final snapshot. It does not create or validate a backup. Data services must remain available. The installer repeats local stop/verification before migration. It starts missing data services without recreating existing containers, then starts matching application services. A failed migration leaves those services stopped; success waits for new service health.
SCANI_SKIP_UP=1prepares configuration only. If no data services or application writers have ever run, keep.env, save a published full semver pin, and use the manual first-boot steps. The backup confirmation is not a first-boot switch. If state is uncertain, establish it before proceeding.
Rollback
Section titled “Rollback”Prefer a compatible forward fix after schema changes. An additive migration does not guarantee old binaries can use the new database. Image-only rollback is unsafe for the quote journal and category changes below.
To downgrade, enter maintenance and stop every application writer. Restore the verified pre-upgrade database snapshot with its matching old images and configuration. Account for writes after that snapshot before restoring it. Rehearse the restore in an isolated database first. Keep traffic disabled until the matching stack passes readiness and data checks. Never treat a portable account export as a schema downgrade.
What CI establishes
Section titled “What CI establishes”CI runs migration and application tests. A clean migration test does not establish
mixed-version fleet compatibility. The maintenance barrier above remains required.
docker-publish.yml publishes five multi-arch images from version tags; PR and
branch-dispatch builds are amd64 smoke checks without publication.
Notes for specific versions
Section titled “Notes for specific versions”0.56.0
Section titled “0.56.0”Coordinated downtime is required when upgrading from 0.55.6. The nullable
holdings.value_quote column changes journal row images. Old API undo can falsely
refuse or try restoring a calculator-owned quote after DDL. The new API handles
historical images, but it must replace the old API before traffic resumes.
Category rules add definitions and retained preview/apply/undo history. New API and erasure workers share an owner lock and a complete erasure manifest. Old workers lack both and can leave rule history behind or fail on category references. Replace all old workers before enabling new category writes. A journal-only bridge does not make a rolling upgrade safe.
All new account exports use backup format 3, including accounts without saved rules. Definitions are included; preview/apply/undo history remains instance-local. New readers accept older formats. Old readers safely refuse format 3, so upgrade a restore destination first. Keep a full pre-upgrade Postgres snapshot for downgrade.
0.53.0
Section titled “0.53.0”New outbound host. Exchange rates are now read from
api.frankfurter.dev; the old api.frankfurter.app only redirects there. If
your install restricts outbound traffic, allow api.frankfurter.dev before
upgrading. No new key and no new environment variable.
A migration can stop this upgrade, and it changes nothing when it does.
20261004084212 adds a check that every stored price in token_prices is a
positive number in plain decimal notation. If any stored row is zero,
negative or written another way, the migrate step (step 3) fails with
23514 naming token_prices_price_positive_decimal_chk. Nothing is applied
and the new version does not start. Check before you upgrade; the answer
must be 0:
docker compose -f docker-compose.prod.yml exec -T postgres psql -U scani -d scani -c " SELECT count(*) FROM token_prices WHERE NOT (CASE WHEN price ~ '^[0-9]{1,64}(\.[0-9]{1,64})?([eE][-+]?[0-9]{1,3})?\$' THEN price::numeric > 0 ELSE false END);"If it is not 0, back the table up first, then delete those rows. Scani
already ignores a price that is not positive, so nothing reads them:
docker compose -f docker-compose.prod.yml exec -T postgres \ pg_dump -U scani --format=custom --no-owner --table=token_prices scani \ > token_prices-before-0.53.0.dump
docker compose -f docker-compose.prod.yml exec -T postgres psql -U scani -d scani -c " DELETE FROM token_prices WHERE NOT (CASE WHEN price ~ '^[0-9]{1,64}(\.[0-9]{1,64})?([eE][-+]?[0-9]{1,3})?\$' THEN price::numeric > 0 ELSE false END);"Then run the check again and continue from step 3.
See also
Section titled “See also”Monthly-budget compatibility boundary
Section titled “Monthly-budget compatibility boundary”The additive migration 20261126010000_monthly_category_budgets_compatibility
introduces budget storage and protects root categories with a native foreign key.
The compatibility build exports and erases budgets, but provides no budget setter,
copy action or UI. It explicitly refuses every portable import containing budget
rows before catalog resolution or target writes. Keep those files for a later
build that supports budget imports; never discard their budget rows.
Portable exports now use format 4, including exports with zero budgets. This build still reads formats 1, 2 and 3 without fabricating budgets. Older readers refuse format 4. An export reads its catalog and account rows in one read-only, repeatable-read snapshot; metadata publication follows the snapshot’s release. Full Postgres backups continue to include the budget table.
Before using this compatibility bridge, verify that the budget table contains no rows. Unexpected existing rows require maintenance with compatible backup and erasure binaries. Never place legacy writers over populated budget storage. Use the stopped-writer procedure above, retain the full snapshot and pin all restarted services and direct runners to the matching compatible artifact. Queued jobs keep their original IDs. Verify old worker processes and active backup, restore and erasure executions have ended; a handed-back job message does not prove process exit.
Budget-producing functionality belongs to a separate subsequent build. Enable it only after every serving API, consuming worker and approved direct runner meets this compatibility floor. Users skipping the bridge can upgrade under the same full maintenance procedure with every old writer stopped.
Once budgets exist, pre-compatibility backup and erasure binaries are unsafe rollback targets. Retain a compatible build or use a forward fix. This bridge can export and erase populated budgets, but still refuses their portable import. Never delete budget rows to permit a downgrade. A database/image rollback needs a matching, verified full backup and must account for changes since that backup.