<p>To upgrade your Appwrite server from an older version, you should use the Appwrite migration tool <b>after you have installed the new version</b>. The migration tool will adjust your Appwrite data to the new version's structure to make sure your Appwrite data is compatible with any internal changes. </p>

<p>As of version 0.14, Appwrite requires <a href="https://docs.docker.com/compose/install/" target="_blank" rel="noopener">Docker Compose Version 2</a>. To upgrade Appwrite, make sure your Docker installation is updated to support Composer V2.</p>

<div class="notice margin-bottom">
    <h3>A Note About Migration</h3>

    <p>At present, we support migrations only to the <b>immediately higher versions</b>, i.e from 0.6 to 0.7 and 0.7 to 0.8 and so on. So if you're trying to migrate from 0.6 to 0.8, you will first need to migrate to 0.7 and then to 0.8</p>

    <p>It is highly recommended to <a href="https://gist.github.com/Meldiron/47b5851663668102a676aff43c6341f7" target="_blank" rel="noopener">backup your server</a> data before running the migration. It is recommended to run the migration process on a dev instance and make sure your application is working well and that you have checked for any breaking changes in the new version <a href="https://github.com/appwrite/appwrite/tags" target="_blank" rel="noopener">changelog.</a></p>
</div>

<p>The first step is to install the latest version of Appwrite. Head to the directory where you ran your previous Appwrite install command. </p>

<div class="ide margin-bottom">
    <pre class="line-numbers"><code class="prism" data-prism>parent_directory <= you run the command in this directory
    └── appwrite
        └── docker-compose.yml</code></pre>
</div>

<p>This is the parent directory where you will find the <b>appwrite</b> directory, inside which there are <b>docker-compose.yml</b> and <b>.env</b> files.</p>

<h3><a href="/docs/upgrade#install-new-version" id="install-new-version">Installing the Next Version</a></h3>

<ul class="phases clear" data-ui-phases>
    
    <li>
    <h4>Unix</h4>
    <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
        <pre class="line-numbers"><code class="prism language-bash" data-prism>docker run -it --rm \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
    --entrypoint="upgrade" \
    appwrite/appwrite:<?php echo APP_VERSION_STABLE; ?></code></pre>
    </div>
    </li>
    <li>
        <h4>CMD</h4>

        <div class="ide margin-bottom" data-lang="bash" data-lang-label="CMD">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>docker run -it --rm ^
    --volume //var/run/docker.sock:/var/run/docker.sock ^
    --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
    --entrypoint="upgrade" ^
    appwrite/appwrite:<?php echo APP_VERSION_STABLE; ?></code></pre>
        </div>
    </li>
    <li>
        <h4>PowerShell</h4>

        <div class="ide margin-bottom" data-lang="bash" data-lang-label="PowerShell">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>docker run -it --rm `
    --volume /var/run/docker.sock:/var/run/docker.sock `
    --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
    --entrypoint="upgrade" `
    appwrite/appwrite:<?php echo APP_VERSION_STABLE; ?></code></pre>
        </div>
    </li>
</ul>

<p>This will pull the <b>docker-compose.yml</b> file for the new version and perform the installation. Once the setup completes, verify that you have the latest version of Appwrite.</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>docker ps | grep appwrite/appwrite</code></pre>
</div>

<p>Verify that the <b>STATUS</b> doesn't have any errors and all the <b>appwrite/appwrite</b> containers have version : <?php echo APP_VERSION_STABLE; ?></p>

<h3><a href="/docs/upgrade#migration" id="migration">Running the Migration</a></h3>
<div class="notice margin-bottom">
    <h3>Upgrading to a minor version</h3>
    <p>You do not need to run migration when upgrading to a minor version. For example, going from 0.13.0 to 0.13.2 would not require running migration.</p>
</div>    
<p>We can now start the migration. Navigate to the <b>appwrite</b> directory where your <b>docker-compose.yml</b> is present and run the following command</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>cd appwrite/
docker compose exec appwrite migrate</code></pre>
</div>

<p>The data migration can take longer depending on the amount of data your Appwrite instance contains. The Appwrite migration command uses multi-threading to speed up the process, meaning that adding more CPU cores can help speed up the process.</p>

<p>Once the migration process has been completed successfully, you're all set to use the latest version of Appwrite!</p>
