Add Prisma migration preflight check to build

This commit is contained in:
Tero Halla-aho 2025-12-20 21:46:29 +02:00
parent 0bfa3d907d
commit 9f3a3b9992

View file

@ -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}