- In Render dashboard, click "New" → "PostgreSQL"
- Name:
hackathon-db - Plan: Free (or paid for production)
- Wait for database to be ready
- Go to your database service in Render
- Copy the "Connection" URL (internal)
- It looks like:
postgresql://user:pass@host:port/dbname
# Install required packages
pip install sqlalchemy psycopg2-binary
# Run migration
python migrate_database.py "postgresql://user:pass@host:port/dbname"- Export Local Data:
# If using SQLite (local)
sqlite3 app.db .dump > local_data.sql
# If using PostgreSQL (local)
pg_dump local_db > local_data.sql- Import to Production:
# Connect to Render database
psql "postgresql://user:pass@host:port/dbname" < local_data.sql-
Access pgAdmin:
- Go to your database in Render
- Click "Connect" → "External Connection"
- Use pgAdmin or similar tool
-
Manual Copy:
- Connect to both databases
- Copy table by table
- Preserve relationships
- Production database will generate new IDs
- Foreign key relationships will be preserved
- Workspace UUIDs will remain the same
- Check for any test data you don't want in production
- Update email addresses if needed
- Verify API keys and secrets
- SQLite to PostgreSQL conversion may need type adjustments
- Dates and timestamps usually convert fine
- JSON fields work in both
- Verify Data Count:
-- Check record counts
SELECT COUNT(*) FROM workspaces;
SELECT COUNT(*) FROM users;
SELECT COUNT(*) FROM booking_types;-
Test Key Functionality:
- Login with existing users
- Check workspace data
- Verify booking types
- Test availability slots
-
Update Environment Variables:
- Set new DATABASE_URL in production
- Test API health endpoint
- Foreign Key Constraints: Import in correct order
- Data Type Mismatches: Adjust column types
- Large Datasets: Import in batches
- Keep local database backup
- Test migration on staging first
- Document the process
For future deployments, consider:
- Alembic migrations for schema changes
- CI/CD pipeline for automated migrations
- Backup strategy for production data