Skip to content
Snippets Groups Projects
Commit d7e4590f authored by Aaron Dötsch's avatar Aaron Dötsch
Browse files

BREAKING: Upgrade postgres from v11.1 to v15.3

I have an update in mind that needs a postgres version newer than the one currently used. So I thought
I'll just update postgres and while I'm already at it I'll just use the newest version. Maybe the
update won't come, maybe it does - nonetheless an upgrade probably can't hurt.

This is a breaking change because postgres refuses to use data from an older postgres version. You
need to manually migrate the data. Just follow these steps:
1. Create backup in case something goes wrong
2. Start the docker container: `docker compose up`
3. Create database dump: `docker compose exec postgres pg_dumpall -U {DB_USERNAME} > dump.sql`
4. Shut down container, delete docker data volume: `docker compose down; rm -rf {POSTGRES_VOLUME_DIRECTORY}`
5. Make sure the dump.sql file is encoded in UTF8 and append `ALTER ROLE "{DB_USERNAME}" PASSWORD '{DB_PASSWORD}';`
6. Start a postgres container: `docker run --rm -v .:/tmp -v {POSTGRES_VOLUME_DIRECTORY}:/var/lib/postgresql/data -w /tmp -e "POSTGRES_PASSWORD={DB_PASSWORD}" -e "POSTGRES_DB={DB_DATABASE}" -e "POSTGRES_USER={DB_USERNAME}" -d postgres:15.3`
7. Wait a bit for the server to start, then import data: `docker exec {CONTAINER_ID} psql -U {DB_USERNAME} -d {DB_DATABASE} -f dump.sql`
8. Stop container: `docker stop {CONTAINER_ID}`
9. Delete temp files: `rm dump.sql`
10. Rebuild the getraenkekasse and start: `docker compose build; docker compose up -d`
parent ae8df7e2
Branches
No related tags found
No related merge requests found
version: '3.8'
services:
postgres:
image: postgres:11.1
image: postgres:15.3
restart: always
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment