Added flask database migration test to CI

This commit is contained in:
Owen 2022-11-14 16:31:15 +00:00
parent 7e0384d698
commit 8a080f3eff
2 changed files with 29 additions and 0 deletions

View file

@ -54,6 +54,12 @@ test:pylint:
- pylint app
allow_failure: true
test:migration:
script:
- cp config.yaml.example config.yaml
- pip install -r requirements.txt --quiet
- sh scripts/test_migrate.sh
pages:
stage: deploy
script:

23
scripts/test_migrate.sh Normal file
View file

@ -0,0 +1,23 @@
#!/bin/sh
set -e
nlines={1..$(flask db history | wc -l)}
# Upgrade to latest db schema
for _ in $nlines
do
flask db upgrade
done
# Downgrade to the first schema
for _ in $nlines
do
flask db downgrade
done
# Upgrade to the latest version again
for _ in $nlines
do
flask db upgrade
done