Files
moyosapp_beta.0.0.3/COOLIFY_DB_QUICKSTART.md
2026-01-15 16:19:14 +02:00

2.1 KiB

Quick Start: Database Migration to Coolify

🚀 Quick Steps

1. Backup Current Database

# Run backup script
./scripts/backup-database.sh

This creates a backup in backups/YYYYMMDD_HHMMSS/ with all your data.

2. Set Up PostgreSQL in Coolify

  1. Create PostgreSQL service in Coolify
  2. Note the container name (e.g., postgres-abc123)
  3. Note the database password

3. Configure Environment Variables

In your Next.js app service in Coolify, set:

DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@postgres-CONTAINER_ID:5432/postgres
RUNTIME_DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@postgres-CONTAINER_ID:5432/postgres

Replace:

  • YOUR_PASSWORD with actual password
  • CONTAINER_ID with actual container ID from Coolify

4. Restore Database

Option A: Via Coolify Terminal

  1. Copy backup to Coolify server
  2. SSH into server or use Coolify terminal
  3. Run restore script:
    ./scripts/restore-database.sh backups/latest
    

Option B: Via Prisma Migrations (Recommended)

# In Coolify build command or manually:
npx prisma migrate deploy
npm run db:seed

5. Verify

Check your app logs in Coolify for database connection errors. Test key features.

📁 Files Created

  • scripts/backup-database.sh - Backup script
  • scripts/restore-database.sh - Restore script
  • scripts/export-db-config.sh - Export config (non-sensitive)
  • docs/COOLIFY_DATABASE_MIGRATION.md - Detailed guide
  • docs/DATABASE_CONFIG.md - Configuration reference

📚 Full Documentation

⚠️ Important Notes

  1. Never commit backups with real data to git
  2. Use strong passwords for production
  3. Test restore in a staging environment first
  4. Keep backups in a secure location

🆘 Need Help?

See troubleshooting section in docs/COOLIFY_DATABASE_MIGRATION.md