Source:
ocean/docs/supabase-deployment-guide.md| ✏️ Edit on GitHub
Supabase Deployment Guide
Overview
Our Supabase deployment is fully automated through GitHub Actions, with local testing via pre-commit hooks to ensure migrations work before they reach production.
Local Development Setup
Prerequisites
- Docker Desktop must be running
- Supabase CLI installed (
brew install supabase/tap/supabase)
Initial Setup
# Link to remote project (one-time setup)
supabase link --project-ref fldiayolmgphysdwgsuk
# Start local Supabase
supabase start
# Your local Supabase will be available at:
# Studio UI: http://localhost:54323
# API: http://localhost:54321
Working with Migrations
-
Create a new migration:
supabase migration new your_migration_name -
Test migrations locally: Migrations are automatically tested when you commit if:
- Local Supabase is running (
supabase start) - You're committing changes to
supabase/migrations/*.sql
The pre-commit hook will run
supabase db resetto ensure all migrations apply cleanly. - Local Supabase is running (
-
Manual testing:
# Reset database and rerun all migrations
supabase db reset
# Check migration status
supabase migration list
Production Deployment
Automatic Deployment
When you push to main, the deploy-supabase.yml workflow automatically:
- Applies any new database migrations
- Deploys Edge Functions
- Updates Edge Function secrets
- Runs health checks
Required GitHub Secrets
The following secrets must be set in GitHub repository settings:
SUPABASE_ACCESS_TOKEN- Your personal access token from Supabase dashboardSUPABASE_DB_PASSWORD- Database password for the projectSUPABASE_PROJECT_ID- The project reference ID (e.g., fldiayolmgphysdwgsuk)SUPABASE_ANON_KEY- Anonymous/public key for health checks
Edge Function Secrets
These are automatically set during deployment:
STRIPE_SECRET_KEYSTRIPE_WEBHOOK_SECRETSTRIPE_FREE_PRICE_IDNEON_API_KEYPOSTHOG_API_KEYPOSTHOG_PROJECT_API_KEYSENTRY_DSN
Troubleshooting
Migration Conflicts
If you encounter migration history mismatches:
# Check migration status
supabase migration list
# Repair migration history if needed
supabase migration repair --status applied <migration_version>
Local Supabase Issues
# Stop all containers
supabase stop
# Start fresh
supabase start
# Check container status
docker ps -a | grep supabase
Pre-commit Hook Failures
If migrations fail during commit:
- Check the error output in terminal
- Review detailed logs at
/tmp/supabase-migration-test.log - Fix the migration SQL
- Run
supabase db resetto test manually - Try committing again
Best Practices
- Always test migrations locally - The pre-commit hook enforces this
- Use descriptive migration names - e.g.,
add_user_preferences_table - Keep migrations idempotent - They should be safe to run multiple times
- Review production logs - Check GitHub Actions logs if deployment fails
- Don't edit existing migrations - Create new ones to fix issues