Skip to content

Upgrading

This page is for the operator who moves a running Adiutor to a new release. It covers what to do beforehand, the upgrade on each kind of host, where the release notes are, how to go back, and the backups that make going back possible.

Every release follows the same order: get the new code, bring the database up to what it expects, and only then serve traffic with it.

  1. Read the release notes (below) for the releases between yours and the new one. A release that needs more than the usual steps says so there.
  2. Back up the database and the attached files, together (see Backups). Migrations only go forward, so the backup is how you go back.
  3. Choose a quiet moment. The site is briefly unavailable while it restarts.
  1. Change the tag of the image in your compose.yaml to the new version. Both the app and the jobs service use the image, so change both lines. The image is bastolen/adiutor, tagged with the release:

    image: bastolen/adiutor:0.5.0
  2. Pull the new image:

    Terminal window
    docker compose pull
  3. Migrate the database with a one-off container, before anything serves the new version:

    Terminal window
    docker compose run --rm app pnpm db:migrate
  4. Start the new version. Compose replaces the app and jobs containers:

    Terminal window
    docker compose up -d

The image never migrates the database by itself, so step 3 is yours every release. If you run the image with docker run instead, do the same with the new tag: pull it, run pnpm db:migrate in a one-off container, then start the new container. See Docker.

Migrations bring the database to what the new code expects. The new build must therefore never serve traffic on the old schema, which is why you migrate before the restart. Migrate again with every release, even one that looks small.

Every release has notes in two places:

  • The changelog in the repository, written for each release by Release Please from the changes in it.
  • The release’s page on GitHub, where a release that needs more from you than the usual steps says so.

Migrations only go forward: there are no migrations that undo a change. Going back to an older version therefore means restoring the backup you took before upgrading, database and files together, and then starting the older version. Anything saved after the backup is lost, so decide quickly and tell people.

With the Compose file, stop the app and the jobs, give the database back its state from the dump, put the older tag back in compose.yaml and start again:

Terminal window
docker compose stop app jobs
docker compose exec -T db dropdb -U adiutor adiutor
docker compose exec -T db createdb -U adiutor adiutor
docker compose exec -T db pg_restore -U adiutor -d adiutor < adiutor.dump
docker compose up -d

Restore the files from the same moment before the last step.

On Vercel, rolling back to an earlier deployment doesn’t undo a migration either: the database keeps the newer schema. See Rolling back.

Back up two things, at the same time, and keep them together:

  • The database. With pg_dump, for example from the Compose database service:

    Terminal window
    docker compose exec -T db pg_dump -U adiutor -Fc adiutor > adiutor.dump

    The -T matters: without it, Compose gives the command a terminal, which can damage the dump on its way to the file.

    With a hosted database, use its own backups, and take one before each upgrade.

  • The attached files, wherever they’re kept: the folder, the bucket or the SFTP folder. A file is found through its row in the database, so a database and its files only make sense as a pair. See Backups and moving storage.

Restore both together: the database from the dump, and the files from the same moment. Test a restore somewhere else before you need it.

Adiutor at https://adiutor.dev runs from /srv/adiutor on a plain server. On a Sunday evening, the operator reads the changelog for the new release, takes a pg_dump and a copy of the files folder, checks out the new tag, installs, builds, migrates and restarts the service. They then open the site, sign in as Alex Admin and check that Logs › Jobs shows a recent tick.

  • When you skip releases, read the notes of every release in between.
  • The Compose jobs service and the cron that runs pnpm jobs:run must run the same version as the app, so upgrade them with it.
  • A pinned tag (0.5.0) keeps a restart from changing the version by accident. Don’t use latest.

Adiutor's code is released under the MIT License. The Adiutor name and logo aren’t covered by it; see the notice.

Set in Inter and JetBrains Mono, under the SIL Open Font License (Inter, JetBrains Mono).