-
-
Notifications
You must be signed in to change notification settings - Fork 32
Upgrading with custom config params
Sam edited this page Jul 1, 2025
·
5 revisions
- You may have custom parameters passed to the
postgrescommand at database startup. - An example could be enabling logical replication for the WAL:
Example via command params:
db:
image: "postgres:14-alpine"
volumes:
- db_data:/var/lib/postgresql/data/
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: db
restart: "unless-stopped"
command: -c 'max_connections=84' -c 'wal_level=logical'Example via environment variable:
db:
image: "postgres:14-alpine"
volumes:
- db_data:/var/lib/postgresql/data/
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: db
POSTGRES_INITDB_ARGS: "-c max_connections=84 -c wal_level=logical"
restart: "unless-stopped"- In order to upgrade these databases, it's mandatory to pass the same connection configuration to pgautoupgrade.
- There are three options to do so:
-
Option 1: include them in
postgresql.conf, which will be retained during the upgrade. -
Option 2: additional args in
commandin your docker / compose config. This should be passed through during the upgrade. -
Option 3: full override of the
POSTGRES_INITDB_ARGS. However, note this requires manually specifying the COLLATE, ENCODING, CTYPE params (else the upgrade will fail), so it only recommended for advanced users.
-
Option 1: include them in
Example upgrade config, using docker compose:
db-upgrade:
image: docker.io/pgautoupgrade/pgautoupgrade:16-3.5-alpine
volumes:
- db-data:/var/lib/postgresql/data
environment:
PGAUTO_ONESHOT: yes
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: db
# DO NOT DO THIS!
# POSTGRES_INITDB_ARGS: "-c wal_level=logical"
network_mode: none
restart: no
command: -c 'wal_level=logical'