#!/bin/sh
set -e

# =============================================================================
# GoodGo API — Docker Entrypoint
#
# Optionally runs Prisma migrations before starting the application.
# Set RUN_MIGRATIONS=true to apply pending migrations on startup.
# In Kubernetes, prefer running migrations as an init container instead.
# =============================================================================

if [ "${RUN_MIGRATIONS}" = "true" ]; then
  echo "[entrypoint] Running Prisma migrations..."
  npx prisma migrate deploy --schema ./prisma/schema.prisma
  echo "[entrypoint] Migrations complete."
fi

exec "$@"
