#!/bin/sh set -e echo "Waiting for PostgreSQL at $DB_HOST:$DB_PORT..." for i in $(seq 1 60); do if nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null; then echo "PostgreSQL is ready" break fi echo "Waiting... $i" sleep 1 done echo "Running Prisma migrations..." # Check if migrations have already been applied if [ -d "prisma/migrations" ] && [ "$(ls -A prisma/migrations 2>/dev/null)" ]; then echo "Applying existing migrations..." npx prisma migrate deploy else echo "Pushing schema to database (first run)..." npx prisma db push --accept-data-loss fi echo "Starting VixTix..." exec npx next start -p 3000