qrmaster/CHANGELOG.md

5.5 KiB

Changelog - PostgreSQL Migration

[2.0.0] - 2024-10-13

🎉 Major Changes - Supabase to PostgreSQL Migration

Removed

  • Supabase dependency - Removed all Supabase-specific configurations
  • DIRECT_URL - Removed connection pooling URL (Supabase-specific)
  • External database dependency - Now fully self-hosted

Added

  • PostgreSQL 16 in Docker - Local PostgreSQL database with Docker support
  • Redis 7 - Caching and rate limiting with Redis
  • Adminer - Database management UI (http://localhost:8080)
  • Docker Compose setups - Both development and production configurations
  • Database initialization - Automated database setup with extensions
  • Complete documentation - Multiple guides for setup and migration
  • Setup scripts - Automated setup for both Linux/Mac and Windows
  • npm scripts - Convenient Docker commands via npm

Modified Files

  • 📝 prisma/schema.prisma - Removed directUrl field
  • 📝 src/lib/env.ts - Removed DIRECT_URL, updated DATABASE_URL default
  • 📝 docker-compose.yml - Complete rewrite with PostgreSQL, Redis, and networking
  • 📝 Dockerfile - Enhanced with proper PostgreSQL support
  • 📝 package.json - Added Docker scripts and tsx dependency
  • 📝 README.md - Updated with new setup instructions

New Files

  • 📄 docker-compose.dev.yml - Development environment (database only)
  • 📄 docker/init-db.sh - PostgreSQL initialization script
  • 📄 docker/README.md - Docker-specific documentation
  • 📄 DOCKER_SETUP.md - Comprehensive Docker setup guide
  • 📄 MIGRATION_FROM_SUPABASE.md - Step-by-step migration guide
  • 📄 env.example - Environment variable template
  • 📄 .dockerignore - Docker build optimization
  • 📄 scripts/setup.sh - Quick setup script (Linux/Mac)
  • 📄 scripts/setup.ps1 - Quick setup script (Windows)
  • 📄 CHANGELOG.md - This file

📦 Docker Services

PostgreSQL Database

  • Image: postgres:16-alpine
  • Port: 5432
  • Features:
    • Health checks
    • Volume persistence
    • UTF-8 encoding
    • Extensions: uuid-ossp, pg_trgm

Redis Cache

  • Image: redis:7-alpine
  • Port: 6379
  • Features:
    • AOF persistence
    • 256MB max memory with LRU eviction
    • Health checks

Next.js Application

  • Port: 3000
  • Features:
    • Multi-stage build
    • Production optimization
    • Health checks
    • Automatic Prisma generation

Adminer (Development)

  • Port: 8080
  • Features:
    • Database management UI
    • Optional (dev profile)
    • Pre-configured for PostgreSQL

🚀 Quick Start

Development Mode

npm run docker:dev    # Start database
npm run db:migrate    # Run migrations
npm run dev           # Start app

Production Mode

npm run docker:prod   # Start all services

📚 Documentation

  • README.md - Main documentation with quick start
  • DOCKER_SETUP.md - Complete Docker guide with troubleshooting
  • MIGRATION_FROM_SUPABASE.md - Migration guide from Supabase
  • docker/README.md - Docker commands and operations
  • env.example - Environment variable reference

🔧 New npm Scripts

# Docker commands
npm run docker:dev         # Start development services
npm run docker:dev:stop    # Stop development services
npm run docker:prod        # Start production stack
npm run docker:stop        # Stop all services
npm run docker:logs        # View all logs
npm run docker:db          # PostgreSQL CLI
npm run docker:redis       # Redis CLI
npm run docker:backup      # Backup database

🔐 Environment Variables

Required

  • DATABASE_URL - PostgreSQL connection string
  • NEXTAUTH_SECRET - NextAuth.js secret (generate with openssl)
  • NEXTAUTH_URL - Application URL
  • IP_SALT - Salt for IP hashing (generate with openssl)

Optional

  • GOOGLE_CLIENT_ID - Google OAuth client ID
  • GOOGLE_CLIENT_SECRET - Google OAuth secret
  • REDIS_URL - Redis connection string
  • ENABLE_DEMO - Enable demo mode

🎯 Benefits

  1. Full Control - Own your data and infrastructure
  2. No Vendor Lock-in - Standard PostgreSQL
  3. Lower Latency - Local network speed
  4. Cost Effective - No monthly database fees
  5. Privacy - Data stays on your infrastructure
  6. Development - Easy local testing
  7. Offline Capable - Works without internet

🔄 Migration Path

  1. Backup Supabase data
  2. Update codebase
  3. Start local PostgreSQL
  4. Restore data or run migrations
  5. Update environment variables
  6. Deploy

See MIGRATION_FROM_SUPABASE.md for detailed steps.

⚠️ Breaking Changes

  • DIRECT_URL environment variable removed
  • Database now requires Docker or local PostgreSQL
  • Supabase-specific features removed

📊 Performance Improvements

  • Local database reduces latency
  • Redis caching improves response times
  • Connection pooling via Prisma
  • Optimized Docker images

🐛 Bug Fixes

  • Fixed database connection handling
  • Improved error messages
  • Better health checks

🔜 Future Enhancements

  • PostgreSQL replication for HA
  • Redis Sentinel for failover
  • Automated backup scripts
  • Monitoring and alerting
  • Database performance tuning
  • Multi-region deployment

📝 Notes

  • Default PostgreSQL password should be changed in production
  • Always backup data before migration
  • Review security settings before deployment
  • Set up automated backups in production

Migration completed successfully! 🎉

For support, see documentation or open an issue on GitHub.