Establish a proper Supabase environment setup with local development, staging, and production environments to enable safe migration testing and deployment workflows.
Current State
supabase/config.toml exists and is configured for local development- 19 migration files exist in
supabase/migrations/ - Supabase CLI is in
devDependencies (supabase@^2.58.5) - README mentions Supabase but lacks detailed local setup instructions
- No documented staging environment
- Production environment exists but migration workflow is manual
Requirements
1. Local Development Environment
Setup:
Commands to document:
# Start local Supabase
supabase start
# Run migrations locally
supabase db reset
# Stop local Supabase
supabase stop
# Access Supabase Studio# Should be available at http://127.0.0.1:54323 (per config.toml)
Environment Variables:
- Document required
.env.local variables for local development - Ensure local Supabase URLs/keys are clearly documented
- Add instructions for linking to local instance vs remote
2. Staging Environment
Setup:
Configuration:
- Staging should mirror production structure
- Use staging for testing migrations before production
- Consider automated deployment to staging on PR creation/updates
GitHub Secrets needed:
STAGING_SUPABASE_PROJECT_IDSTAGING_SUPABASE_ACCESS_TOKENSTAGING_SUPABASE_DB_PASSWORD (if needed)
3. Production Environment
Setup:
GitHub Secrets needed:
SUPABASE_PROJECT_ID (production)SUPABASE_ACCESS_TOKEN (production)SUPABASE_DB_PASSWORD (production, if needed)
4. Environment Management
Documentation:
Scripts/Tooling:
Implementation Considerations
Local Development:
- Ensure Docker is installed (required for
supabase start) - Document port conflicts and how to resolve them
- Document how to seed local database with test data
- Consider adding a seed script for local development
Staging Environment:
- Should be created as a separate Supabase project
- Consider using Supabase's free tier for staging
- Set up automated testing of migrations in staging
- Document how to sync staging data from production (if needed)
Production Environment:
- Ensure proper backup strategy is documented
- Document rollback procedures for failed migrations
- Set up monitoring/alerting for migration failures
- Consider using Supabase's migration history tracking
Security:
- All production credentials must be in GitHub secrets
- Never commit
.env.local files - Document least-privilege access principles
- Consider using Supabase's project linking feature
CI/CD Integration:
- Staging migrations could run on PR creation
- Production migrations should run only on merge to
master - Consider adding migration validation step before deployment
- Add migration status checks to PR checks
File Structure
After implementation, the project should have:
docs/
supabase-setup.md # Comprehensive setup guide
.env.local.example # Template for local environment variables
supabase/
config.toml # Already exists (local config)
migrations/ # Already exists
seed.sql # Seed file (if needed)
Acceptance Criteria
Related Issues
Notes
- Supabase CLI requires Docker to be running for local development
- Local Supabase Studio is available at
http://127.0.0.1:54323 (per supabase/config.toml) - Consider using Supabase's
supabase link command to connect to remote projects - Migration files should be tested locally before pushing to staging/production
- Consider adding a pre-commit hook to validate migration SQL syntax
Resources
This issue covers:
- Local, staging, and production setup
- Documentation requirements
- Security considerations
- CI/CD integration points
- Acceptance criteria
- Related issues
Copy this into a new GitHub issue.
Establish a proper Supabase environment setup with local development, staging, and production environments to enable safe migration testing and deployment workflows.
Current State
supabase/config.tomlexists and is configured for local developmentsupabase/migrations/devDependencies(supabase@^2.58.5)Requirements
1. Local Development Environment
Setup:
.env.local.exampletemplate fileCommands to document:
Environment Variables:
.env.localvariables for local development2. Staging Environment
Setup:
Configuration:
GitHub Secrets needed:
STAGING_SUPABASE_PROJECT_IDSTAGING_SUPABASE_ACCESS_TOKENSTAGING_SUPABASE_DB_PASSWORD(if needed)3. Production Environment
Setup:
GitHub Secrets needed:
SUPABASE_PROJECT_ID(production)SUPABASE_ACCESS_TOKEN(production)SUPABASE_DB_PASSWORD(production, if needed)4. Environment Management
Documentation:
docs/supabase-setup.mdwith comprehensive setup guideScripts/Tooling:
Implementation Considerations
Local Development:
supabase start)Staging Environment:
Production Environment:
Security:
.env.localfilesCI/CD Integration:
masterFile Structure
After implementation, the project should have:
Acceptance Criteria
docs/supabase-setup.mdcreated with comprehensive guide.env.local.exampletemplate file createdRelated Issues
Notes
http://127.0.0.1:54323(persupabase/config.toml)supabase linkcommand to connect to remote projectsResources
This issue covers:
Copy this into a new GitHub issue.