==========================
Upgrading Postgres version
==========================

Current versions of Workbench no longer support Postgres versions 9.6 and older. To align with these changes, you must update your Postgres to a supported version. To simplify this process, Anaconda provides a script that automates the update, minimizing downtime and ensuring a smooth transition. See which Postgres versions are compatible with your version of Workbench in the latest :ref:`release notes <latest_release>`.

Checking your Postgres version
==============================

You can check your current version of Postgres by running the following command in your cluster: 

.. tab-set:: 

    .. tab-item:: BYOK8s

        .. code-block:: none

            # Replace <NAMESPACE> with your namespace (default is anaconda-enterprise)
            kubectl exec -it anaconda-enterprise-postgres-0 -n <NAMESPACE> -- psql --version

    .. tab-item:: Gravity

        .. code-block:: none

            kubectl exec -it anaconda-enterprise-postgres-0 -- psql --version

Upgrading Postgres
==================

You must place a compatible version of Postgres in the same registry as the current Postgres image prior to performing the upgrade. 

.. caution:: 

    If you are upgrading your Workbench version, complete that process first, then return here. 

#. :ref:`Create a backup of your cluster <run_backup>`. 

#. Pause your instance of Workbench by running the following command:

    .. code-block:: none

        ae_pause.sh

#. Use the restore script to update your version of Postgres to a compatible version by running the following command:

    .. code-block:: none

        # Replace <VERSION> with the new Postgres version image number
        bash ae_restore.sh ae5_config_db_YYYYMMDDHHMM.tar.gz ae5_data_YYYYMMDDHHMM.tar.gz --db-version=<VERSION>

#. Unpause your instance of Workbench by running the following command:

    .. code-block:: none

        ae_unpause.sh