2
0
mirror of https://github.com/inventree/inventree-website.git synced 2026-02-15 10:10:27 +00:00
Files
inventree-website/blog/2026/02/12/db-update.html
SchrodingersGat de4c0e66d3 deploy: 3a22a9dfc5
2026-02-14 23:57:56 +00:00

307 lines
16 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang=" en-US ">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/assets/splide/css/splide.min.css">
<link rel="stylesheet" href="/assets/index.css">
<link rel="shortcut icon" type="image/png" href="/assets/icon/favicon.ico">
<script src="/assets/splide/js/splide.min.js"></script>
<!-- Fontawesome integration -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
<title>InvenTree - Database Update Procedure</title>
<meta itemprop="description" name="description"
content="InvenTree is an open-source inventory management system which provides intuitive parts management and stock control. It is at the center of an ecosystem of a..." />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Database Update Procedure | InvenTree</title>
<meta name="generator" content="Jekyll v4.3.3" />
<meta property="og:title" content="Database Update Procedure" />
<meta name="author" content="SchrodingersGat" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="In our recent 1.2.0 release, we updated our underlying django version to from 4.2 to 5.2." />
<meta property="og:description" content="In our recent 1.2.0 release, we updated our underlying django version to from 4.2 to 5.2." />
<link rel="canonical" href="/blog/2026/02/12/db-update" />
<meta property="og:url" content="/blog/2026/02/12/db-update" />
<meta property="og:site_name" content="InvenTree" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2026-02-12T00:00:00+00:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Database Update Procedure" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"SchrodingersGat"},"dateModified":"2026-02-12T00:00:00+00:00","datePublished":"2026-02-12T00:00:00+00:00","description":"In our recent 1.2.0 release, we updated our underlying django version to from 4.2 to 5.2.","headline":"Database Update Procedure","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/2026/02/12/db-update"},"url":"/blog/2026/02/12/db-update"}</script>
<!-- End Jekyll SEO tag -->
</head>
<body class="flex flex-col antialiased cm-gray-1 min-h-screen">
<div class="flex-none">
<header class="cm-gray-2 body-font sticky top-0 z-50 bg-gradient-to-r from-white to-secondary">
<div class="container mx-auto flex flex-wrap p-5 flex-row items-center">
<a class="flex title-font font-medium items-center cm-gray-1 mb-0 mr-2" href="/">
<img src="/assets/logo.png" alt="logo" height="32" width="32" class="h-8">
<span class="ml-3 text-xl">InvenTree</span>
</a>
<div class="flex-grow xs:flex-none"></div>
<nav class="md:mr-auto md:py-1 xs:ml-4 xs:pl-4 xs:border-l xs:border-gray-400 flex flex-wrap items-center text-base justify-center">
<a class="mr-5 hover:cm-gray-1" href="/deploy.html">Deploy</a>
<a class="mr-5 hover:cm-gray-1" href="https://docs.inventree.org/en/stable/">Docs</a>
<a class="mr-5 hover:cm-gray-1" href="/blog">Blog</a>
</nav>
</div>
</header> <header>
<a href="/blog" class="flex items-center m-5 text-xl hover:underline">
<img class="w-6 h-6" alt="go back" src="/assets/back.svg">
<span>Back</span>
</a>
</header>
<article>
<h1>Database Update Procedure</h1>
<p>
12 Feb 2026
<a href="/schrodingersgat">Oliver</a>
</p>
<p>In our <a href="/blog/2026/02/12/1.2.0">recent 1.2.0 release</a>, we updated our underlying <a href="https://www.djangoproject.com/">django</a> version to from 4.2 to 5.2.</p>
<p>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.</p>
<p>If you are attempting to update to InvenTree 1.2.0 while still running PostgreSQL 13, you will encounter the following error message:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>django.db.utils.NotSupportedError: PostgreSQL 14 or later is required (found 13.23).
</code></pre></div></div>
<p>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.</p>
<h2 id="migration-guide">Migration Guide</h2>
<p>Our documentation provides a detailed <a href="https://docs.inventree.org/en/stable/start/migrate/#migrating-between-incompatible-database-versions">database migration guide</a> 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.</p>
<p>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.</p>
<p>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.</p>
<h2 id="starting-conditions">Starting Conditions</h2>
<p>The starting conditions for this migration are as follows:</p>
<ul>
<li>InvenTree is installed via docker / docker compose (as per the <a href="https://docs.inventree.org/en/stable/start/docker_install/">docker installation instructions</a>)</li>
<li>The InvenTree version is pinned to 1.1.12 in the <code class="language-plaintext highlighter-rouge">.env</code> file</li>
<li>The database is running PostgreSQL 13 (set via the <code class="language-plaintext highlighter-rouge">docker-compose.yml</code> file).</li>
</ul>
<p><img src="/assets/blog/db_update_env.png" alt=".env file"></p>
<p><img src="/assets/blog/db_update_compose.png" alt=".docker-compose.yml file"></p>
<p>We also have a data directory, external to the docker containers, with the following structure:</p>
<p><img src="/assets/blog/db_update_data.png" alt="Data directory"></p>
<h3 id="target-conditions">Target Conditions</h3>
<p>The new installation will be running InvenTree 1.2.0 with PostgreSQL 17</p>
<h2 id="step-1-perform-backup">Step 1. Perform Backup</h2>
<p>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.</p>
<p>First, lets confirm that we are running the expected version of InvenTree (1.1.12).</p>
<p><img src="/assets/blog/db_update_old_versions.png" alt="Old Setup"></p>
<p>To perform the backup, we run the following command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose run --rm inventree-server invoke backup
</code></pre></div></div>
<p>This will create a backup of the database and media files in the <code class="language-plaintext highlighter-rouge">data/backup</code> directory.</p>
<p>Confirm that the backup files have been created before continuing to the next step.</p>
<h2 id="step-2-move-database-directory">Step 2. Move Database Directory</h2>
<p>The PostgreSQL database files are stored in the <code class="language-plaintext highlighter-rouge">data/pgdb</code> 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.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mv data/pgdb data/pgdb_backup
</code></pre></div></div>
<p>Confirm that the <code class="language-plaintext highlighter-rouge">pgdb</code> directory has been moved to the backup location before continuing to the next step. The <code class="language-plaintext highlighter-rouge">pgdb</code> directory should no longer exist in the <code class="language-plaintext highlighter-rouge">data</code> directory.</p>
<h2 id="step-3-update-postgresql-version">Step 3. Update PostgreSQL Version</h2>
<p>Next, we need to update the PostgreSQL version in the <code class="language-plaintext highlighter-rouge">docker-compose.yml</code> file. Change the version from <code class="language-plaintext highlighter-rouge">13</code> to <code class="language-plaintext highlighter-rouge">17</code>:</p>
<p><img src="/assets/blog/db_update_new_postgres.png" alt="Update PostgreSQL version"></p>
<p>Pull down the updated docker images:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose pull
</code></pre></div></div>
<h2 id="step-4-restore-data-from-backup">Step 4. Restore Data from Backup</h2>
<p>Now we can restore the data from the backup we created previously, into the new PostgreSQL 17 database. Run the following commands:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose run --rm inventree-server invoke migrate
docker compose run --rm inventree-server invoke restore
</code></pre></div></div>
<p>This will restore the database and media files from the backup we created previously.</p>
<h2 id="step-5-update-inventree-version">Step 5. Update InvenTree Version</h2>
<p>Next, we need to update the InvenTree version in the <code class="language-plaintext highlighter-rouge">.env</code> file. Change the version from <code class="language-plaintext highlighter-rouge">1.1.12</code> to <code class="language-plaintext highlighter-rouge">1.2.0</code>:</p>
<p><img src="/assets/blog/db_update_new_inventree.png" alt="Update InvenTree version"></p>
<p>Then, we need to pull down the updated InvenTree server image:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose pull
</code></pre></div></div>
<p>Next, run the InvenTree update procedure:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose run --rm inventree-server invoke update
</code></pre></div></div>
<h2 id="step-6-verify-new-setup">Step 6. Verify New Setup</h2>
<p>Finally, we can start the new setup and verify that everything is working as expected.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker compose up -d
</code></pre></div></div>
<p>Then, you should be able to access your InvenTree instance again, and confirm that you are running the new version (1.2.0):</p>
<p><img src="/assets/blog/db_update_new_versions.png" alt="New Setup"></p>
<p>We can also see that the correct versions of both PostgreSQL and InvenTree are running in the docker containers:</p>
<p><img src="/assets/blog/db_update_docker.png" alt="Docker containers"></p>
<h2 id="step-7-celebrate">Step 7. Celebrate!</h2>
<p>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.</p>
<p>Please consider <a href="/contribute.html#sponsor">sponsoring the project</a>, to help us continue to maintain and improve InvenTree for all users. Your support is greatly appreciated!</p>
</article>
</div>
<div class="flex-grow"></div>
<div class="flex-none">
<footer class="cm-gray-2 body-font">
<div class="container px-5 pt-8 mx-auto flex md:flex-row md:flex-nowrap flex-wrap flex-col">
<div class="w-64 flex-shrink-0 md:mx-0 mx-auto text-center md:text-left">
<div class="flex title-font font-medium items-center md:justify-start justify-center cm-gray-1">
<img src="/assets/logo.png" alt="logo" height="32" width="32" class="h-8">
<span class="ml-3 text-xl">InvenTree</span>
</div>
<p class="mt-2 text-sm cm-gray-3">Intuitive Inventory Management</p>
</div>
<div class="flex-grow flex flex-wrap md:pl-10 mb-1 md:mt-0 mt-10 md:text-left text-center md:justify-left justify-center">
<div class="md:w-1/4 px-4">
<h2 class="footer-categorie title-font">
Quick
</h2>
<nav class="list-none mb-10"><ul>
<li><a href="/demo.html" class="footer-link">Demo</a></li>
<li><a href="/deploy.html" class="footer-link">Deploy</a></li>
<li><a href="https://docs.inventree.org/en/stable/" class="footer-link">Docs</a></li>
<li><a href="/news" class="footer-link">News</a></li>
<li><a href="/plugins" class="footer-link">Plugin List</a></li>
</ul></nav>
</div>
<div class="md:w-1/4 px-4">
<h2 class="footer-categorie title-font">
<a href="/extend/">Ecosystem</a>
</h2>
<nav class="list-none mb-10"><ul>
<li><a href="/extend/api.html" class="footer-link">API</a></li>
<li><a href="/extend/app.html" class="footer-link">App</a></li>
<li><a href="/extend/plugin/" class="footer-link">Plugins</a></li>
<li><a href="/extend/integrate/" class="footer-link">Integrations</a></li>
</ul></nav>
</div>
<div class="md:w-1/4 px-4">
<h2 class="footer-categorie title-font">
Sitemap
</h2>
<nav class="list-none mb-10"><ul>
<li><a href="/about/" class="footer-link">About</a></li>
<li><a href="/alternatives/" class="footer-link">Alternatives</a></li>
<li><a href="/blog" class="footer-link">Blog</a></li>
<li><a href="/contribute.html" class="footer-link">Contribute</a></li>
<li><a href="/support.html" class="footer-link">Support</a></li>
</ul></nav>
</div>
</div>
</div>
<div class="bg-gray-100">
<div class="container mx-auto py-4 px-5 flex flex-wrap flex-col sm:flex-row">
<p class="cm-gray-2 text-sm text-center sm:text-left">© 2021-now InvenTree by<a href="https://github.com/inventree" rel="noopener" class="cm-gray-2 ml-1" target="_blank">@inventree</a>— website made with ♥ by<a href="https://github.com/matmair" rel="noopener" class="cm-gray-2 ml-1" target="_blank">@matmair</a></p>
<span class="inline-flex sm:ml-auto sm:mt-0 mt-2 justify-center sm:justify-start">
<span class="invisible"><a rel="me" href="https://chaos.social/@InvenTree">Mastodon</a></span>
<a href="https://github.com/inventree/inventree" alt="github repo" class="ml-3 cm-gray-3">
<img class="h-5 w-5" alt="GitHub logo" src="/assets/github.svg">
</a>
<a href="https://reddit.com/r/inventree" alt="Reddit" class="ml-3 cm-gray-3">
<img class="h-5 w-5" alt="Reddit logo" src="/assets/reddit.svg">
</a>
<a href="https://twitter.com/inventreedb" alt="Twitter" class="ml-3 cm-gray-3">
<img class="h-5 w-5" alt="Twitter logo" src="/assets/twitter.svg">
</a>
<a href="https://chaos.social/@InvenTree" rel="me" alt="Mastodon" class="ml-3 cm-gray-3">
<img class="h-5 w-5" alt="Mastodon logo" src="/assets/mastodon.svg">
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>