# Upgrade a PostgreSQL Cluster

DBaaS supports upgrading a PostgreSQL cluster to a higher major version in-place. To do so, issue a `PATCH` request containing the target `postgresVersion`.

## Endpoint

Use the following endpoint to upgrade your PostgreSQL cluster:`https://api.ionos.com/databases/postgresql/clusters/{clusterId}`

{% hint style="info" %}
**Note:** The sample UUID is `498ae72f-411f-11eb-9d07-046c59cc737e`.
{% endhint %}

## Request

```bash
curl --include \
    --request PATCH \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    --data-binary '{
      "metadata": {},
      "properties": {
        "postgresVersion": "16"
      }
    }' \
```

## Response

```json
{
  "type": "cluster",
  "id": "498ae72f-411f-11eb-9d07-046c59cc737e",
  "metadata": {
    "state": "AVAILABLE",
    "createdDate": "2020-12-10T12:37:50.000Z",
    "createdBy": "clientname@ionos.com",
    "createdByUserId": "012342f-411f-1eeb-9d07-046c59cc737e",
    "lastModifiedDate": "2020-12-18T21:37:50.000Z",
    "lastModifiedBy": "clientname@ionos.com",
    "lastModifiedByUserId": "012342f-411f-1eeb-9d07-046c59cc737e"
  },
    "properties": {
        "displayName": "an even better name",
        "location": "de/txl",
        "dnsName": "pg-pgov71sjg1c875ji.postgresql.de-txl.ionos.com",
        "connections": [
            {
                "datacenterId": "db7e8811-cfae-4b40-82ee-2f4cff81e105",
                "lanId": "2",
                "cidr": "10.7.222.3/23"
            }
        ],
        "cores": 1,
        "postgresVersion": "16",
        "ram": 4096,
        "instances": 1,
        "storageSize": 102400,
        "storageType": "HDD",
        "maintenanceWindow": {
            "dayOfTheWeek": "Wednesday",
            "time": "12:08:00"
        },
        "synchronizationMode": "ASYNCHRONOUS",
        "connectionPooler": {
            "enabled": false,
            "poolMode": "transaction"
        }
    }
}
```

The upgrade procedure is efficient and should only take a few minutes, even for large databases. The database will be unavailable, potentially multiple times, until the upgrade is complete. Once the upgrade is complete, a new backup is automatically created.

Once the upgrade is triggered, it cannot be undone. If the upgrade fails or causes unexpected behavior in the application, you can restore the old state by creating a new database from the previous backup. An in-place restore will only apply the old data and not roll back to the older PostgreSQL version.

{% hint style="danger" %}
**Caution:** Executing in-place upgrades cause the removal of database objects and extensions that are deemed incompatible with the target version. To mitigate potential application failure, always test the upgrade against a database clone to confirm stability before proceeding.
{% endhint %}

.
