forked from ungleich-public/dynamicweb
Add a script to restore the snapshot into the compose stack
This commit is contained in:
parent
b003bbcc52
commit
8c1cfcfc11
2 changed files with 29 additions and 0 deletions
15
legacy-snapshot/README.md
Normal file
15
legacy-snapshot/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Old-version database snapshot
|
||||
|
||||
`django-1.9.sql.gz` is a dump of the sample database made on the original
|
||||
Django 1.9 stack (no real or personal data). It stands in for an old
|
||||
production database: after each upgrade step, restore it and let the new
|
||||
version migrate it.
|
||||
|
||||
```sh
|
||||
sh legacy-snapshot/restore.sh
|
||||
docker compose exec web python smoke_test.py # after the site answers (~1.5 min)
|
||||
```
|
||||
|
||||
It holds the sample sites and pages from `seed_dummy_data` plus what
|
||||
`seed_extra.py` adds: blog posts, contact messages, hosting plans and
|
||||
supporters. Real production rows are the one thing it cannot cover.
|
||||
14
legacy-snapshot/restore.sh
Normal file
14
legacy-snapshot/restore.sh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
# Replaces the database of the running compose stack with the Django 1.9
|
||||
# snapshot, then restarts the app (its start-up runs "migrate").
|
||||
# Use it to check that an upgraded version can migrate old data:
|
||||
# sh legacy-snapshot/restore.sh
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
docker compose stop web celery
|
||||
docker compose exec -T db psql -U app -d postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'app' AND pid <> pg_backend_pid()" > /dev/null
|
||||
docker compose exec -T db psql -U app -d postgres -c "DROP DATABASE IF EXISTS app"
|
||||
docker compose exec -T db psql -U app -d postgres -c "CREATE DATABASE app OWNER app"
|
||||
gunzip -c legacy-snapshot/django-1.9.sql.gz | docker compose exec -T db psql -U app -d app -q -v ON_ERROR_STOP=1 > /dev/null
|
||||
docker compose up -d web celery
|
||||
echo "Restored. The site answers after about 1.5 minutes; then run: docker compose exec web python smoke_test.py"
|
||||
Loading…
Add table
Add a link
Reference in a new issue