Add Prisma migration preflight check to build

This commit is contained in:
Tero Halla-aho 2025-12-20 21:46:29 +02:00
parent 0635a49702
commit b89f7ce129

View file

@ -81,6 +81,17 @@ for tool in git npm; do
done done
check_docker check_docker
check_age_setup 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) GIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || date +%s)
BASE_TAG=${BUILD_TAG:-$GIT_SHA} BASE_TAG=${BUILD_TAG:-$GIT_SHA}