From 89d52cca5ebdc87c730619800084429a1f25aec2 Mon Sep 17 00:00:00 2001 From: Chris Parsons <438676+chrisparsons83@users.noreply.github.com> Date: Sun, 5 Apr 2026 22:50:23 -0400 Subject: [PATCH] Run database migrations on deploy before starting container (#264) Migrations were never being run against production on deploy, causing schema mismatches when new columns are added. This adds a migration step using the PROD_DATABASE_URL secret before bringing up the new container, with set -e to abort the deploy if migrations fail. Co-authored-by: Claude Sonnet 4.6 --- .github/workflows/deploy.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7a3ad81..4f09bcc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -138,16 +138,20 @@ jobs: REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + PROD_DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }} with: host: ${{ secrets.DEPLOY_HOST }} port: ${{ secrets.DEPLOY_PORT }} username: ${{ secrets.DEPLOY_USER }} key: ${{ secrets.DEPLOY_KEY }} - envs: REGISTRY_USERNAME,REGISTRY_PASSWORD,CONTAINER_REGISTRY + envs: REGISTRY_USERNAME,REGISTRY_PASSWORD,CONTAINER_REGISTRY,PROD_DATABASE_URL script: | + set -e + IMAGE="$CONTAINER_REGISTRY/brackt:latest" docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD cd brackt docker compose pull + docker run --rm -e DATABASE_URL="$PROD_DATABASE_URL" "$IMAGE" npx drizzle-kit migrate docker compose up -d sleep 10 if docker compose ps | grep -qE "Exit|exited"; then