# Upgrade the minor version

Apply a newer minor release of the same PostgreSQL major now, instead of waiting for the maintenance window.

Minor releases are bug and security fixes with no format change. They are applied in the
maintenance window, or when you ask. Replace _ewdb-0123456789ab_ with your database's id.

## Prerequisites

- In the console, also `rds:DescribeDBInstances` to open the database's page (without it the page
  is not found).
- Permission for `rds:ModifyDBInstance`. Without it the console shows no upgrade button.
- The database is **available**. Otherwise the request is refused with `409` "Cannot upgrade while
  the database is …".
- Machines with a maintenance agent that answers. Machines built before in-place upgrades cannot be
  upgraded here; **Maintenance** says so, they get the current version when they are replaced, and
  the API refuses with `409` "… cannot be upgraded in place: built before in-place upgrades, or its
  agent is not answering".

## Upgrade now

**Console**
1. Open the database, then choose the **Maintenance** tab. The table shows what each node runs,
   and the section says which newer minor is available.
2. Choose **Upgrade to _version_ now**.
3. In the browser's confirmation, choose **OK**. The tab says "Upgrade requested; it starts within
   a minute."

**CLI**
```sh
dcloud rds instances upgrade ewdb-0123456789ab --engine-version 17.12
```

Without `--engine-version`, the minor the platform currently offers for the database's major.

**API**
```http
POST /rds/api/instances/ewdb-0123456789ab/upgrade
{ "engineVersion": "17.12" }
```

`{}` upgrades to the minor offered for the database's major. The answer is `202`. A version that
is not offered is refused with `400` "PostgreSQL … is not offered (…; offered: …)", and one the
database already runs with `400` "The database already runs …".

**Terraform:** not available. An upgrade is an action; Terraform sets `engine_version` only at creation.

## Result

A **cluster** is upgraded one node at a time: replicas first, each streaming again before the next.
Leadership then moves by switchover to an upgraded node, and the old leader is upgraded last. Writes
pause for a few seconds during the switchover. A **single node** restarts once and is unavailable
for that restart.

The database is `maintenance` meanwhile, and each step is on **Activity** (phase `upgrade`), ending
with "PostgreSQL … on every node". If a step fails, the database returns to `available`, the event
"The upgrade to … stopped: …" says which node runs which version, and asking again finishes the
rest: nodes already on the target are skipped.

## Related

- [Versions and maintenance](versions-and-maintenance.md)
- [Set the maintenance window](set-the-maintenance-window.md)
- `rds.instances.upgrade` · `dcloud rds instances upgrade`
