- Install backend and frontend dependencies - Fix Prisma schema BigInt default values - Generate Prisma client - Create database setup script and documentation - Add DATABASE_SETUP.md guide
56 lines
1.7 KiB
Bash
Executable File
56 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Database setup script for ASLE backend
|
|
# This script helps set up PostgreSQL database for development
|
|
|
|
set -e
|
|
|
|
echo "=== ASLE Database Setup ==="
|
|
echo ""
|
|
|
|
# Check if PostgreSQL is running
|
|
if ! pg_isready -h localhost -p 5432 > /dev/null 2>&1; then
|
|
echo "❌ PostgreSQL is not running on localhost:5432"
|
|
echo ""
|
|
echo "Please start PostgreSQL:"
|
|
echo " - Using Docker: docker-compose up -d postgres"
|
|
echo " - Using systemd: sudo systemctl start postgresql"
|
|
echo " - Or install PostgreSQL: sudo apt install postgresql"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ PostgreSQL is running"
|
|
echo ""
|
|
|
|
# Try to connect and create database
|
|
echo "Attempting to create database 'asle'..."
|
|
|
|
# Try different connection methods
|
|
if psql -U postgres -c "CREATE DATABASE asle;" 2>/dev/null; then
|
|
echo "✅ Database 'asle' created using postgres user"
|
|
DB_USER="postgres"
|
|
elif psql -d postgres -c "CREATE DATABASE asle;" 2>/dev/null; then
|
|
echo "✅ Database 'asle' created using peer authentication"
|
|
DB_USER=$(whoami)
|
|
else
|
|
echo "⚠️ Could not create database automatically"
|
|
echo ""
|
|
echo "Please create the database manually:"
|
|
echo " psql -U postgres -c \"CREATE DATABASE asle;\""
|
|
echo ""
|
|
echo "Or update backend/.env with correct DATABASE_URL:"
|
|
echo " DATABASE_URL=\"postgresql://username:password@localhost:5432/asle?schema=public\""
|
|
echo ""
|
|
read -p "Press Enter after creating the database..."
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Database Setup Complete ==="
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Update backend/.env with correct DATABASE_URL"
|
|
echo " 2. Run: cd backend && npm run prisma:migrate"
|
|
echo " 3. Run: npm run setup:db"
|
|
echo " 4. Run: npm run setup:admin"
|
|
|