From 24b4364869c429562a607e08f1ec79065bd79720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Thu, 23 Nov 2023 08:39:07 +0100 Subject: [PATCH] chore: migrate before deployment --- .github/workflows/container-deploy.yml | 8 ++++++++ Makefile | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/container-deploy.yml b/.github/workflows/container-deploy.yml index a151af56..e2b43469 100644 --- a/.github/workflows/container-deploy.yml +++ b/.github/workflows/container-deploy.yml @@ -147,10 +147,16 @@ jobs: script_stop: false script: | cd ${{ matrix.env }} + # Get the latest version (to apply migration next) + make pull + # Apply migrations + make migrate-db + # Launch new version make up - name: Check services are up uses: appleboy/ssh-action@master + id: livecheck if: ${{ always() }} with: host: ${{ env.SSH_HOST }} @@ -162,6 +168,8 @@ jobs: script_stop: false script: | cd ${{ matrix.env }} + # Let 10s to the API to be up + sleep 10 make livecheck - name: Cleanup obsolete Docker objects diff --git a/Makefile b/Makefile index 5ab5590f..daa056ed 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,11 @@ create_external_volumes: @echo "🥫 Creating external volumes (production only) …" docker volume create open_prices_postgres-data + +migrate-db: + @echo "🥫 Migrating database …" + ${DOCKER_COMPOSE} run --rm --no-deps api poetry run alembic upgrade head + #---------# # Cleanup # #---------#