Skip to content

Upgrade Procedure

Upgrading Katalogue to a newer version is fairly simple and normally follows the same procedure, as described here. Note that there might be differences depending on your specific deployment.

This is the general procedure to upgrade Katalogue to a newer version. It uses the upgrade script for the database. To do the same by hand, see Manual Upgrade.

  1. Check the changelog for any version-specific deviations from this upgrade procedure.

  2. Download the new release from the official Katalogue GitHub repo.

  3. Stop the api and worker services. The upgrade locks the tables they use, and waits at most 30 seconds for a lock before it gives up.

  4. Upgrade the repository database with the upgrade script, from the services/db folder of the new release. It does steps 4 and 5 of the manual upgrade: it backs up the database, then applies every delta script between the current version and the new one. See Running the Database Upgrade Script below.

  5. Deploy the new api and spa services and start them.

  6. Verify that all Katalogue services have the same, and the intended, version.

    • The spa version is displayed when hovering over the info-icon in the upper right corner of the GUI.
    • The api version is displayed when navigating to the api service base url in the browser, e.g. https://demo-api.katalogue.se.
    • The database version is available in the public.version table.

    When they start, the API and the worker log their own version and the repository database’s on the startup entry (event.action sys_startup), as katalogue.version and katalogue.database_version, and log a warning when the two differ. In the log file, every entry also carries the service’s version as service.version.

  7. Run the Rebuild Search Index task.

  8. Verify that everything works by clicking around in the GUI, running a datasource sync job etc.

The script reads the version the database is at from public.version, finds the delta scripts in services/db/deltas it needs to reach the new version, and shows what it is about to do:

Terminal window
./upgrade.sh -h <hostname> -p <port> -U <admin username>
Database: katalogue on db.example.com:5432
Current version: 0.23.1
Target version: 0.25.0
Applies: 0.24.0 0.25.0
Backup: /home/admin/katalogue_backup_0.23.1_20261110T183000Z.dump

After you confirm, it backs up the database and applies all the versions in one transaction. If any of them fails, nothing is changed: the database stays at the version it was at, and you can fix the cause and run the script again.

Compared with applying the delta scripts by hand, the script also picks the scripts and their order from the version the database is at, and checks after each one that it set the version it should.

By default the script upgrades to the newest version in the release you downloaded. To stop at an earlier one, pass it with -t:

Terminal window
./upgrade.sh -h <hostname> -p <port> -U <admin username> -t 0.24.0

--dry-run runs the whole upgrade against your database, then rolls it back. It proves that the upgrade applies to that database without changing it. It locks the same tables as a real upgrade, so stop the api and worker for it too.

Terminal window
./upgrade.sh -h <hostname> -p <port> -U <admin username> --dry-run

Before upgrading, the script backs up the katalogue database with pg_dump, to katalogue_backup_<version>_<timestamp>.dump in the current folder. <version> is the version before the upgrade. The file is readable only by the user running the script, since it contains everything in the database. Restore it as described in Database Backup.

  • -o <folder> puts the backup elsewhere.
  • --backup-format picks the pg_dump format: custom (the default, compressed), plain (an SQL file), tar or directory.
  • --no-backup skips it, for example when your platform takes its own backups. Then take one yourself before upgrading.

The backup holds the katalogue database, not the PostgreSQL roles, which belong to the server. To back those up too, see Backup Roles.

The script needs a pg_dump of the same major version as the server, or newer, and stops before changing anything if it does not have one.

To run the script unattended, for example from a deployment pipeline, give it the admin password and pass -y:

  1. Give the admin password in one of these ways:
    • In a file passed with -e, holding POSTGRES_PASSWORD=<admin password>. Make it readable only by you, as for the install script.
    • In the PGPASSWORD environment variable.
    • In ~/.pgpass, as for psql.
  2. Run the script with -y, so it does not ask for confirmation. Without a terminal to ask on, it stops unless -y is given.
    Terminal window
    ./upgrade.sh -h <hostname> -p <port> -U <admin username> -y

The script exits with 0 when the database was upgraded or was already up to date, 1 when it refused to start, for example because of an unknown version or a missing pg_dump, and 3 when the upgrade failed and was rolled back. Two upgrades of the same database at the same time cannot interleave: the second one stops.

OptionDescriptionDefault
-h, --hostnamePostgreSQL hostnamelocalhost
-p, --portPostgreSQL port5432
-U, --usernamePostgreSQL admin account usernamepostgres
-e, --env-fileFile to read the admin password from
-t, --toVersion to upgrade tonewest in deltas/
-y, --yesDo not ask for confirmation
--dry-runRun the upgrade and roll it back
--no-backupDo not back up before upgrading
-o, --backup-dirFolder for the backupcurrent folder
--backup-formatcustom, plain, tar or directorycustom
-v, --verboseShow everything psql and pg_dump print, including notices and the details of an error. By default the script prints only its plan, its progress and any errors.
--helpShow the usage text

The script trusts the version recorded in public.version. If this for some reason is wrong, you can set it manually to the correct version in the database by running:

UPDATE public.version SET version_number = '0.23.1';

This is the same upgrade done by hand, without the upgrade script. Steps 4 and 5 are the ones the upgrade script does for you.

  1. Check the changelog for any version-specific deviations from this upgrade procedure.

  2. Download the new release from the official Katalogue GitHub repo.

  3. Stop the api and worker services.

  4. Back up the repository database.

  5. Apply the delta scripts in services/db/deltas, one at a time and in version order, starting with the version after the one the database is at. The version is in the public.version table. Apply each one as an admin, in a transaction of its own:

    Terminal window
    psql -h <hostname> -p <port> -U <admin username> -d katalogue -1 -v ON_ERROR_STOP=1 -f deltas/<version>.sql

    E.g. to upgrade from 0.23.1 to 0.25.0, apply 0.24.0.sql, then 0.25.0.sql. A delta script only contains the changes from the version before it.

    -1 runs the script in one transaction and ON_ERROR_STOP stops it at the first error, so a script that fails changes nothing. The scripts do not start a transaction themselves, so if you run them from another tool, wrap each one in BEGIN; and COMMIT;. Scripts that already ran stay applied: after fixing the cause of a failure, continue from the script that failed.

  6. Deploy the new api and spa services and start them.

  7. Verify that all Katalogue services have the same, and the intended, version, as in the procedure above.

  8. Run the Rebuild Search Index task.

  9. Verify that everything works by clicking around in the GUI, running a datasource sync job etc.