Upgrade
Upgrades may change the database schema. Schema changes rely on Django's migrate tool, which depends on the migrations directories created during installation and on the django_migrations table. Do not delete or modify these directories or the table, otherwise upgrades that change the schema may leave columns missing.
If you run v2.x.x (see System Settings / About), do not upgrade to v3 or v4 with the upgrade tool; it will break the installation! #419
Upgrading from 3.x to 4.0
4.0 upgrades the core back-end dependencies (Python 3.8+, Django 4.2, channels 4, paramiko 3.4). The 3.x runtime and Docker image cannot run 4.0 code, so follow these steps:
Docker install
manage.py update would pip-install the 4.0 Python dependencies into the 3.x container, and they are lost as soon as the container is recreated. It is only meant for updates between 4.x versions; to go from 3.x to 4.0 switch the image as described below.
- Back up the database and the data directory:
docker exec spug-db mysqldump -uroot -pspug.cc spug > spug-backup.sqlcp -r /data/spug /data/spug.bak
- Edit
docker-compose.yml: change the image of thespugservice toopenspug/spug-service:4.0and addSPUG_DOCKER_VERSION=v4.0.1to itsenvironment(everything else stays the same), then recreate the containers:spug:image: openspug/spug-service:4.0environment:- SPUG_DOCKER_VERSION=v4.0.1- MYSQL_DATABASE=spug# ... the remaining settings stay unchangedcd /data/spugdocker compose up -d - Inside the container check out
v4.0.1, download the matching front-end bundle and apply the schema changes (existing data such as the administrator account and execution templates, as well as your custom settings inoverrides.py, are kept):docker exec spug bash -c 'cd /data/spug && git fetch origin --tags && git checkout v4.0.1 && curl -fo /tmp/web.tar.gz https://cdn.spug.cc/spug/web_v4.0.1.tar.gz && rm -rf spug_web/build && tar xf /tmp/web.tar.gz -C spug_web/ && python3 spug_api/manage.py updatedb' - Restart the container, confirm that
System Settings / Aboutshowsv4.0.1and force-refresh the browser:docker restart spug
The latest tag on Docker Hub is still 3.3.3, so docker compose pull alone does not give you 4.0. Even with the 4.0 image, the container leaves the existing code in /data/spug/service untouched on start, which is why step 3 switches the code by hand. Without it the 3.x code runs on Django 4.2: the container reports running, but every API request fails.
Manual deployment
- Back up the database.
- Install Python 3.8 or later and rebuild the virtual environment:
cd /data/spug/spug_apigit fetch origin --tags && git checkout v4.0.1rm -rf venv && python3 -m venv venvsource venv/bin/activatepip install -U pip setuptoolspip install -r requirements.txt mysqlclient -i https://pypi.tuna.tsinghua.edu.cn/simple/python manage.py updatedb
- Download the 4.0 front-end bundle
https://cdn.spug.cc/spug/web_v4.0.1.tar.gzand extract it intospug_web(it creates thebuilddirectory). - Make sure the
spug-wsprogram insupervisorusestools/start-ws.sh(daphne), then runsupervisorctl restart all.
Updating between 4.x versions
The commands below are only for updates between 4.x versions; to upgrade from 3.x to 4.0 follow the previous section.
Docker install
# updates to the latest version by default
# spug is the container name, replace it with your container ID if needed
docker exec -i spug python3 /data/spug/spug_api/manage.py update
# restart the container afterwards
docker restart spug
Manual deployment
# updates to the latest version by default
cd spug_api
source venv/bin/activate
python manage.py update
# restart the services
supervisorctl restart all
manage.py update checks for a new version and shows its release notes. After confirmation it downloads the front-end bundle, checks out the matching tag of the back-end, updates the dependencies and applies schema changes. When the installation is already up to date, a repair update (re-fetching the current version) can be chosen instead.