#!/bin/bash

# Database setup script for Prmbr
echo "🚀 Setting up Prmbr database..."

# Check if .env file exists
if [ ! -f .env ]; then
    echo "❌ .env file not found. Please create one with DATABASE_URL"
    exit 1
fi

# Generate Prisma client
echo "📦 Generating Prisma client..."
npx prisma generate

# Push schema to database (for development)
echo "🗄️  Pushing schema to database..."
npx prisma db push

# Optional: Open Prisma Studio
read -p "🎨 Do you want to open Prisma Studio? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo "🎨 Opening Prisma Studio..."
    npx prisma studio
fi

echo "✅ Database setup complete!"
echo "💡 You can now run: npm run dev"
