go back Back

Database Update Procedure

12 Feb 2026 Oliver

In our recent 1.2.0 release, we updated our underlying django version to from 4.2 to 5.2.

For users running with a PostgreSQL database, Django 5.2 requires a minimum version of PostgreSQL 14. This means that users running PostgreSQL 13 will need to perform a manual update of their database in order to continue using InvenTree with the latest version.

If you are attempting to update to InvenTree 1.2.0 while still running PostgreSQL 13, you will encounter the following error message:

django.db.utils.NotSupportedError: PostgreSQL 14 or later is required (found 13.23).

In such a case, you will need to perform a database update procedure to migrate your existing database from PostgreSQL 13 to PostgreSQL 14 (or later). This process involves backing up your existing database, installing the new version of PostgreSQL, and then restoring your data into the new database.

Migration Guide

Our documentation provides a detailed database migration guide to assist users with this process. We recommend that users perform a backup of their database before attempting the migration, and follow the instructions carefully to ensure a smooth transition to the new database version.

Following is an example of the steps involved in migrating an InvenTree installation from a PostgreSQL 13 database to a PostgreSQL 17 database, in the context of a docker installation. The same principles apply for non-docker installations, but the particular commands may differ.

PostgreSQL 17 is recommended as the target version, as it is supported by both the 1.1.x and 1.2.x versions of InvenTree.

Starting Conditions

The starting conditions for this migration are as follows:

.env file

.docker-compose.yml file

We also have a data directory, external to the docker containers, with the following structure:

Data directory

Target Conditions

The new installation will be running InvenTree 1.2.0 with PostgreSQL 17

Step 1. Perform Backup

The first step is to perform a backup of the existing database. This step must be performed with the old setup (postgres 13 / InvenTree 1.1.12), before we perform any updates to the software.

First, let’s confirm that we are running the expected version of InvenTree (1.1.12).

Old Setup

To perform the backup, we run the following command:

docker compose run --rm inventree-server invoke backup

This will create a backup of the database and media files in the data/backup directory.

Confirm that the backup files have been created before continuing to the next step.

Step 2. Move Database Directory

The PostgreSQL database files are stored in the data/pgdb directory. We need to remove these files, as they are specific to PostgreSQL 13 and will not be compatible with PostgreSQL 17. Rather than deleting them, we will move them to a backup location, just in case we need to revert back to the old setup.

mv data/pgdb data/pgdb_backup

Confirm that the pgdb directory has been moved to the backup location before continuing to the next step. The pgdb directory should no longer exist in the data directory.

Step 3. Update PostgreSQL Version

Next, we need to update the PostgreSQL version in the docker-compose.yml file. Change the version from 13 to 17:

Update PostgreSQL version

Pull down the updated docker images:

docker compose pull

Step 4. Restore Data from Backup

Now we can restore the data from the backup we created previously, into the new PostgreSQL 17 database. Run the following commands:

docker compose run --rm inventree-server invoke migrate
docker compose run --rm inventree-server invoke restore

This will restore the database and media files from the backup we created previously.

Step 5. Update InvenTree Version

Next, we need to update the InvenTree version in the .env file. Change the version from 1.1.12 to 1.2.0:

Update InvenTree version

Then, we need to pull down the updated InvenTree server image:

docker compose pull

Next, run the InvenTree update procedure:

docker compose run --rm inventree-server invoke update

Step 6. Verify New Setup

Finally, we can start the new setup and verify that everything is working as expected.

docker compose up -d

Then, you should be able to access your InvenTree instance again, and confirm that you are running the new version (1.2.0):

New Setup

We can also see that the correct versions of both PostgreSQL and InvenTree are running in the docker containers:

Docker containers

Step 7. Celebrate!

Congratulations! You have successfully migrated your InvenTree installation to the latest version, with an updated PostgreSQL database. You can now enjoy the new features and improvements that come with InvenTree 1.2.0, while also benefiting from the enhanced performance and security of PostgreSQL 17.

Please consider sponsoring the project, to help us continue to maintain and improve InvenTree for all users. Your support is greatly appreciated!