de973f5613
Test and Lint / backend-test (push) Successful in 1m9s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m15s
Version and Release / version-bump (push) Successful in 36s
Version and Release / trigger-drone (push) Successful in 4s
Major fixes for production deployment issues: 1. Migration System: - Add safe migration runner that handles existing schema - Create migration helper functions for idempotent operations - Auto-detect existing tables and mark migrations as applied - Handle "relation already exists" errors gracefully 2. Production Initialization: - Create init-production.sh script for proper startup sequence - Fix directory creation and permissions - Add admin user creation from environment variables - Ensure proper service initialization order 3. Documentation: - Add comprehensive PRODUCTION_DEPLOYMENT_GUIDE.md - Add MIGRATION_ERROR_FIX.md for immediate issue resolution - Document all known production issues and solutions - Include backup/restore procedures 4. Safety Improvements: - Add migrate:safe npm script for production use - Update wait-for-db.sh to use safe migrations in production - Add proper error handling and logging This resolves the "relation already exists" error and prevents similar issues in future deployments. The safe migration system can handle both fresh installations and existing databases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
698 B
Bash
Executable File
29 lines
698 B
Bash
Executable File
#!/bin/sh
|
|
# wait-for-db.sh - Wait for PostgreSQL to be ready before starting the application
|
|
|
|
set -e
|
|
|
|
host="$DB_HOST"
|
|
port="${DB_PORT:-5432}"
|
|
user="${DB_USER:-picpeak}"
|
|
|
|
echo "Waiting for PostgreSQL at $host:$port..."
|
|
|
|
# Wait for PostgreSQL to be ready
|
|
until PGPASSWORD=$DB_PASSWORD psql -h "$host" -p "$port" -U "$user" -d "${DB_NAME:-picpeak}" -c '\q' 2>/dev/null; do
|
|
>&2 echo "PostgreSQL is unavailable - sleeping"
|
|
sleep 2
|
|
done
|
|
|
|
>&2 echo "PostgreSQL is up - executing command"
|
|
|
|
# Run migrations (use safe runner in production)
|
|
echo "Running database migrations..."
|
|
if [ "$NODE_ENV" = "production" ]; then
|
|
npm run migrate:safe
|
|
else
|
|
npm run migrate
|
|
fi
|
|
|
|
# Execute the main command
|
|
exec "$@" |