From 8a080f3effc8a6f7ad428132fdc70b50b0995077 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 14 Nov 2022 16:31:15 +0000 Subject: [PATCH] Added flask database migration test to CI --- .gitlab-ci.yml | 6 ++++++ scripts/test_migrate.sh | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/test_migrate.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 28c5902..f5e37b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/scripts/test_migrate.sh b/scripts/test_migrate.sh new file mode 100644 index 0000000..5d0a04d --- /dev/null +++ b/scripts/test_migrate.sh @@ -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 \ No newline at end of file