Upgrading from postgres 15 -> 16-alpine. (#4426)

- Includes an upgrade script.
- Fixes #4406
This commit is contained in:
Dessalines 2024-02-07 05:21:02 -05:00 committed by GitHub
parent 3647a46e86
commit 9367cbdb00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 3 deletions

View File

@ -257,7 +257,7 @@ steps:
services:
database:
image: postgres:15.2-alpine
image: postgres:16-alpine
environment:
POSTGRES_USER: lemmy
POSTGRES_PASSWORD: password

View File

@ -99,7 +99,7 @@ services:
logging: *default-logging
postgres:
image: postgres:15-alpine
image: postgres:16-alpine
# this needs to match the database host in lemmy.hson
# Tune your settings via
# https://pgtune.leopard.in.ua/#/

View File

@ -20,7 +20,7 @@ x-lemmy-default: &lemmy-default
restart: always
x-postgres-default: &postgres-default
image: postgres:15-alpine
image: postgres:16-alpine
environment:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password

View File

@ -0,0 +1,42 @@
#!/bin/sh
set -e
echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete."
echo "Stopping lemmy and all services..."
sudo docker-compose stop
echo "Make sure postgres is started..."
sudo docker-compose up -d postgres
echo "Waiting..."
sleep 20s
echo "Exporting the Database to 15_16.dump.sql ..."
sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 15_16_dump.sql
echo "Done."
echo "Stopping postgres..."
sudo docker-compose stop postgres
echo "Waiting..."
sleep 20s
echo "Removing the old postgres folder"
sudo rm -rf volumes/postgres
echo "Updating docker-compose to use postgres version 16."
sed -i "s/image: postgres:.*/image: postgres:16-alpine/" ./docker-compose.yml
echo "Starting up new postgres..."
sudo docker-compose up -d postgres
echo "Waiting..."
sleep 20s
echo "Importing the database...."
cat 15_16_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy
echo "Done."
echo "Starting up lemmy..."
sudo docker-compose up -d
echo "A copy of your old database is at 15_16.dump.sql . You can delete this file if the upgrade went smoothly."
echo "Upgrade complete."