Overview
This runbook guides you through migrating your LatentGEO deployment from one Supabase region to another. Common scenarios include:- Reducing latency by moving closer to users
- Compliance requirements (data residency)
- Disaster recovery preparation
- Cost optimization
Prerequisites
Create Target Project
Create a new Supabase project in the target region:
- Log in to Supabase Dashboard
- Click “New Project”
- Select target region (e.g.,
us-east-1,eu-west-1,ap-southeast-1) - Configure project settings
- Note the project URL and API keys
Migration Process
Phase 1: Database Backup
Create Database Dump
Create a full backup of the source database:
The
--no-owner and --no-privileges flags ensure compatibility with the target database’s ownership structure.Phase 2: Database Restore
Restore to Target Database
Some errors about missing roles or extensions are normal. Supabase manages these automatically.
Verify Table Counts
Run this query on both source and target databases:Verify counts match exactly between source and target.
Phase 3: Storage Migration
Create Target Bucket
In the Supabase Dashboard for the target project:
- Navigate to Storage
- Create bucket named
audit-reports - Set appropriate policies (public read or private)
Phase 4: Configuration Update
Update Environment Variables
Update these variables in your deployment environment (Docker Compose, AWS ECS, etc.):
Update CI/CD Secrets
If using GitHub Actions or similar:
- Update repository secrets
- Update environment variables in CI/CD platform
- Update AWS Secrets Manager (if applicable)
Phase 5: Cutover
Validate Critical Paths
Test these key functions:
- User authentication
- Create new audit
- View existing reports
- SSE real-time updates
- Storage access (PDF downloads)
- Webhook delivery
Verification Checklist
Database Verification
- All table row counts match
- Latest data is present (check created_at timestamps)
- Foreign key relationships intact
- Indexes exist (
\diin psql) - No missing sequences
Storage Verification
- File count matches
- Sample files download correctly
- File sizes match
- MIME types preserved
- Storage policies configured
Application Verification
- Health endpoint returns 200
- User login works
- Create new audit completes
- SSE events stream correctly
- Reports generate successfully
- PDF downloads work
- Webhooks deliver
- Background jobs process
Rollback Procedure
Identify Issue
Common rollback triggers:
- Database connection failures
- Data inconsistencies
- High error rates (>5%)
- Storage access failures
- Unacceptable latency increase
Post-Migration Tasks
Monitor Costs
- Compare billing between old and new projects
- Verify no unexpected charges
- Adjust database compute if needed
Update Documentation
- Update connection strings in team docs
- Update runbooks with new project refs
- Document lessons learned
Supported Compose Files
This migration procedure works with both Docker Compose configurations:docker-compose.yml- Standard production modedocker-compose.dev.yml- Development mode with hot reload
Troubleshooting
Migration Errors
pg_restore: error: role 'postgres' does not exist
pg_restore: error: role 'postgres' does not exist
This is normal when using
--no-owner. Supabase manages roles automatically. The restore will continue.pg_restore: error: extension 'uuid-ossp' already exists
pg_restore: error: extension 'uuid-ossp' already exists
This is normal. Supabase pre-installs common extensions. Use
--if-exists flag to suppress these errors.Connection timeout during large restore
Connection timeout during large restore
For databases >5GB:
Storage upload fails with 'Bucket not found'
Storage upload fails with 'Bucket not found'
Verify bucket exists in target project:Create if missing via Dashboard or CLI.
Performance Issues
High database latency after migration
High database latency after migration
Check the region distance:If latency is >100ms, verify:
- Application and database are in same region
- No network issues between regions
- Database is properly sized
SSE reconnection storms
SSE reconnection storms
If you see excessive SSE reconnections:Ensure
SSE_SOURCE=redis and Redis is accessible.Next Steps
Docker Deployment
Configure Docker Compose with new Supabase credentials
AWS Deployment
Update ECS task definitions with migrated database