From b89f7ce129000cf66fd9b4445f2b7d94acf47d43 Mon Sep 17 00:00:00 2001 From: Tero Halla-aho Date: Sat, 20 Dec 2025 21:46:29 +0200 Subject: [PATCH] Add Prisma migration preflight check to build --- deploy/build.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deploy/build.sh b/deploy/build.sh index a04292f..1c3f0b3 100755 --- a/deploy/build.sh +++ b/deploy/build.sh @@ -81,6 +81,17 @@ for tool in git npm; do done check_docker check_age_setup +if [[ -z "${SKIP_DB_MIGRATION_CHECK:-}" ]]; then + if command -v npx >/dev/null 2>&1; then + echo "Checking for pending Prisma migrations..." + if ! npx prisma migrate status >/dev/null 2>&1; then + echo "Prisma migrate status failed. Ensure DATABASE_URL is set and migrations are up to date." >&2 + exit 1 + fi + else + echo "npx not found; skipping Prisma migration check." >&2 + fi +fi GIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || date +%s) BASE_TAG=${BUILD_TAG:-$GIT_SHA}