Version: 2.0.0Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Last Updated: 2026-01-15
Purpose: Create a Supabase staging environment using branches to validate migrations before production.
Overview
This guide uses Supabase Branches (recommended) for staging instead of creating a separate project. Branches provide:- ✅ Isolated database environment
- ✅ Automatic migration sync via GitHub
- ✅ Cost-effective (included in plan)
- ✅ Easy switching between environments
Option A: Use Supabase Branch (Recommended)
Step 1: Verify Prerequisites
Use MCP:Step 2: Create Persistent Staging Branch
Use CLI (Required for creation):Step 3: Verify Branch Creation
Use MCP:Step 4: Link Local Project to Staging Branch
Use CLI:Step 5: Apply All Migrations
Use CLI:Step 6: Verify Database State
Use MCP:| Module | Prefix | Expected |
|---|---|---|
| Platform Foundation | pf_ | ~74 |
| Human Resources | hr_ | ~94 |
| Finance & Accounting | fa_ | ~46 |
| Forms & Workflow | fw_ | ~54 |
| Recovery Housing | rh_ | ~51 |
| Governance & Risk | gr_ | ~49 |
| Facilities Management | fm_ | ~22 |
| Leadership OS | lo_ | ~29 |
| IT Service Management | it_ | ~35 |
| Total | ~465 |
Step 7: GitHub Integration Setup (Recommended)
Purpose: Auto-deploy migrations when pushing tostaging Git branch.
Via Supabase Dashboard:
- Go to Project Settings → Integrations → GitHub
- Click “Connect to GitHub”
- Authorize repository access
- Configure branch mapping:
mainGit branch → SupabasemainprojectstagingGit branch → Supabasestagingbranch
- Create a test Git branch
- Add a simple migration
- Push to Git
- Check Supabase dashboard for auto-deployment
Step 8: Set Environment Variable
For local development:Option B: Create Separate Project (Alternative)
Use this if branching is not available on your Supabase plan.Step 1: Create Staging Project
- Go to Supabase Dashboard
- Click “New Project”
-
Configure:
- Name:
encoreos-staging - Database Password: Generate strong password (save securely)
- Region: Same as production project
- Pricing Plan: Free tier is sufficient for testing
- Name:
- Wait for project to be provisioned (~2 minutes)
Step 2: Link and Apply Migrations
Step 3: Verify Database State
Same as Option A, Step 6.Quick Verification Checklist
Run these to verify staging is set up correctly:MCP Checks
-
mcp_supabase_list_branches()shows staging branch -
mcp_supabase_list_tables()returns ~465 tables -
mcp_supabase_list_migrations()shows 393+ migrations -
mcp_supabase_get_advisors({ type: "security" })returns no critical issues
CLI Checks
-
supabase statusshows linked to staging -
supabase migration listshows all migrations applied
Troubleshooting
Issue: Branch creation fails
Symptom:supabase --experimental branches create returns error
Solutions:
- Check Supabase plan includes branching feature
- Ensure CLI is latest version:
npm install -g supabase - Verify authentication:
supabase login
Issue: Cannot link to branch
Symptom:supabase link --project-ref fails
Solutions:
- Verify branch project ID is correct (from dashboard or MCP)
- Check if project exists:
supabase projects list - Re-authenticate if needed:
supabase login
Issue: Migration fails with “relation already exists”
Symptom:supabase db push reports errors
Solutions:
- Some migrations may have been partially applied
- Check migration history in Supabase dashboard
- If safe, reset and reapply:
supabase db reset(WARNING: deletes data)
Issue: Table counts don’t match expected
Symptom: MCP returns fewer tables than expected Solutions:- Check for migration errors in Supabase dashboard → Database → Migrations
- Some tables may be in other schemas (check
auth,storage) - Verify all migrations applied:
mcp_supabase_list_migrations()
Issue: GitHub integration not auto-deploying
Symptom: Pushing to Git doesn’t trigger migration deployment Solutions:- Verify GitHub integration is connected in dashboard
- Check branch mapping is correct
- Review webhook delivery logs in GitHub repository settings
- Ensure migration files are in
supabase/migrations/directory
Seeding Staging Database
After migrations are applied, seed the staging database with test data.Seed File Structure
Generate Seed Files
Validate Seeds
Apply Seeds to Staging
Verify Seed Data
Using Supabase MCP:00000000- prefix UUIDs)
Safety Guidelines
- ⚠️ NEVER run seeds in production
- Seeds use deterministic UUIDs (
00000000-prefix) - Seeds use test email domain (
@staging.encoreos.io) - Always verify project/branch before seeding
Next Steps
Once staging is set up and seeded:- Run SQL Audits: See SQL_AUDIT_INSTRUCTIONS.md
- Create Fix Migrations: Use templates in
supabase/migrations/TEMPLATE_*.sql - Generate TypeScript Types: See TYPE_GENERATION_GUIDE.md
- Test Application: Point app at staging environment variables
- Verify Environment Isolation: Run
npm run test:isolation
Related Documentation
- Completion Plan - Full migration plan
- MCP Usage Guide - When to use MCP vs CLI
- Supabase Branching - Official docs
Last Updated: 2026-01-15
Version: 2.0.0