31 lines
879 B
Bash
31 lines
879 B
Bash
#!/bin/sh
|
|
# Backend startup script - ensures database is initialized before starting server
|
|
|
|
set -e # Exit on error (except for seed script)
|
|
|
|
echo "🔍 Checking database..."
|
|
echo "Database host: ${DB_HOST}"
|
|
echo "Database name: ${DB_NAME}"
|
|
|
|
# Run seed script - capture exit code but continue
|
|
echo "🌱 Running database seed script..."
|
|
if node database/seed-postgres.js; then
|
|
echo "✅ Seed script completed successfully"
|
|
else
|
|
SEED_EXIT_CODE=$?
|
|
echo "⚠️ Seed script exited with code ${SEED_EXIT_CODE}"
|
|
echo " This is normal if data already exists"
|
|
fi
|
|
|
|
# Run migrations
|
|
echo "🔄 Running database migrations..."
|
|
if node database/run-migrations.js; then
|
|
echo "✅ Migrations completed successfully"
|
|
else
|
|
MIGRATION_EXIT_CODE=$?
|
|
echo "⚠️ Migrations exited with code ${MIGRATION_EXIT_CODE}"
|
|
fi
|
|
|
|
echo "🚀 Starting server..."
|
|
node server.js
|