# Upgrade

> Schema migrations and gateway upgrades.

---

LLMS index: [llms.txt](/llms.txt)

---

Upgrading `pgsilo` across schema versions requires a planned maintenance window. Because a database schema migration does not automatically stop running gateway binaries, **never run mixed gateway schema versions concurrently** against the same PostgreSQL database.

## Coordinated upgrade sequence {#upgrade-sequence}

1. **Record current versions and take a physical backup**: record the running `silo` binary checksums and `schema_version`, take a verified physical backup ([Backup and restore](/docs/s3/operations/backup/)), and confirm external SSE-S3 KMS keys are backed up.
2. **Stop all gateways and SQL writers**: drain client traffic, stop every writable and read-only `silo` gateway, disable automatic systemd/supervisor restarts, and pause direct `silo_api` SQL writer jobs. Verify in `pg_stat_activity` that all gateway sessions have exited.
3. **Install the new binary on all gateway hosts** and verify SHA-256 checksums.
4. **Migrate the database from a single writable gateway**: start **one** writable gateway connected to the PostgreSQL primary. On startup, it applies pending migrations inside a transaction as `silo_owner`. Never attempt schema migration from a read-only gateway.
5. **Verify schema 14 and health endpoints**: confirm the first gateway passes `/minio/health/cluster/read` and `/minio/health/cluster`, and verify the migration ledger in `silo.meta`.
6. **Start remaining gateways**: start the other writable gateways, wait for physical standbys to replay the schema migration WAL, and then start read-only standby gateways.
7. **Run post-upgrade verification** before reopening client traffic: test plaintext and encrypted reads, versions, multipart completion, annotations, ZIP extraction, IAM allow/deny rules, and maintenance lease acquisition (`minio_pg_lifecycle_leader`).

As `silo_owner` or a database administrator, inspect the migration ledger with:

```sql
SELECT key, value
FROM silo.meta
WHERE key = 'schema_version' OR key LIKE 'migration:%'
ORDER BY key;
```

In the current build, `schema_version` must be `14`, and entries `migration:0001` through `migration:0014` must match the SHA-256 migration hashes embedded in the `silo` binary. Never grant application roles access to `silo.meta` or manually edit migration rows.

## Summary of historical schema versions {#schema-history}

| Schema version | Key changes | Compatibility boundary |
| --- | --- | --- |
| Schema 12 | Added checksum metadata compatibility verification (`CRC64NVME`, `SHA512`, `XXHASH*`) | Schema 11 binaries cannot interpret new checksum type bits and are rejected after schema 12 commits |
| Schema 13 | Added object annotations, transactional quota counters, `copy_object` annotation support, and deferred annotation payload cleanup | Schema 12 binaries are rejected after schema 13 commits |
| Schema 14 | Added persistent random UUID `revision_token` to the control-plane revision table so gateways detect split-brain IAM state after failover | Schema 13 binaries are rejected after schema 14 commits |
{.wide}

When upgrading across builds that corrected region lookup precedence (`MINIO_REGION` > `MINIO_REGION_NAME` > `MINIO_SITE_REGION` > persisted site region), also verify that no gateway environment file carries an unintended legacy `MINIO_REGION_NAME` override. See [Configuration: Region selection](/docs/s3/reference/configuration/#region-selection).

## Rollback rules {#rollback}

Once a schema migration transaction commits in PostgreSQL, older gateway binaries refuse to start against that database. If a migration fails or you must roll back to an earlier schema version:

- First check `silo.meta` in PostgreSQL to see whether the migration transaction actually committed (a lost network connection does not prove rollback).
- Never decrement `schema_version`, alter `migration:*` hashes, or drop columns manually to force an older binary to start.
- To revert to an older schema version, perform a full physical restore from your pre-upgrade backup and WAL archive.

---

Backlinks:

- [Operations](/docs/s3/operations/)
- [Install](/docs/s3/operations/install/)
- [Deploy with Pigsty](/docs/s3/operations/pigsty/)
