partdoc/migrate_postgres.sh

12 lines
599 B
Bash

# start old postgres, dump data
sed -i 's/postgres:12-alpine/postgres:10-alpine/' docker-compose.yml
docker-compose exec web python3 manage.py dumpdata -o /app/djangodump0.json --natural-foreign --exclude auth.permission --exclude contenttypes --indent 1
# migrate to new postgres, import data
docker-compose down
mv pgdata __pgdata__10
sed -i 's/postgres:10-alpine/postgres:12-alpine/' docker-compose.yml
docker-compose up -d
docker-compose exec web python3 manage.py migrate
docker-compose exec web python3 manage.py loaddata /app/djangodump0.json
docker-compose exec web rm /app/djangodump0.json