Skip to content

Commit be3f268

Browse files
authored
Upgrade Postgres to 16.3 to match prdouction (#256)
This requires a couple changes: * If you keep the same data dir, postgres gets annoyed about the data dir being old, so this swaps a new one. * Before applying this, you can backup your data with ``inv docker.manage --backupdb shell`` * After applying, you can run: ``` inv docker.shell --container database --no-running docker cp dump_*.sql community_database_1:/tmp/dump.sql dropdb -U docs_user docs_db createdb -U docs_user docs_db psql -U docs_user docs_db < dump_*.sql # ALTER USER docs_user WITH ENCRYPTED PASSWORD 'docs_pwd'; ```
1 parent 3a5c44f commit be3f268

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

dockerfiles/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
volumes:
22
build-user-builds:
33
storage_data:
4-
postgres_data:
4+
postgres_data_16:
55
postgres_backups_data:
66

77
services:
@@ -305,14 +305,14 @@ services:
305305
readthedocs:
306306

307307
database:
308-
image: postgres:12.17
308+
image: postgres:16.3
309309
environment:
310310
- POSTGRES_USER=docs_user
311311
- POSTGRES_PASSWORD=docs_pwd
312312
- POSTGRES_DB=docs_db
313313
volumes:
314314
- ${PWD}/common/dockerfiles/entrypoints/postgres.sql:/docker-entrypoint-initdb.d/postgres.sql
315-
- postgres_data:/var/lib/postgresql/data
315+
- postgres_data_16:/var/lib/postgresql/data
316316
- postgres_backups_data:/backups
317317
networks:
318318
readthedocs:

dockerfiles/tasks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ def manage(c, command, running=True, backupdb=False):
131131
if running:
132132
subcmd = 'exec'
133133

134+
# After you run this and upgrade the DB:
135+
# inv docker.shell --container database --no-running
136+
# dropdb -U docs_user docs_db
137+
# createdb -U docs_user docs_db
138+
# psql -U docs_user docs_db < dump_*.sql
139+
# If upgrading Postgres versions, you may need to run:
140+
# ALTER USER docs_user WITH ENCRYPTED PASSWORD 'docs_pwd';
134141
if backupdb:
135142
c.run(f'{DOCKER_COMPOSE_COMMAND} {subcmd} database pg_dumpall -c -U docs_user > dump_`date +%d-%m-%Y"_"%H_%M_%S`__`git rev-parse HEAD`.sql', pty=True)
136143

0 commit comments

Comments
 (0)