Date: 2026-01-15Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Status: Ready to Execute
Key Findings from Supabase Documentation Review
✅ Use Supabase Branches (Not Separate Projects)
Discovery: Supabase supports branching for staging/testing environments. Benefits:- No need to create/manage separate projects
- Automatic migration sync via GitHub integration
- Easy branch switching in dashboard
- Cost-effective (included in plan)
- Isolated databases per branch
✅ RLS WITH CHECK is Critical
Confirmed: UPDATE policies MUST have WITH CHECK clause to preventorganization_id modification.
From Supabase Docs:
“TheOur Status: 118 UPDATE policies missing WITH CHECK (P0 - Critical) Action: Create migration to add WITH CHECK to all affected policies.usingclause represents the condition that must be true for the update to be allowed, andwith checkclause ensures that the updates made adhere to the policy constraints.”
✅ Migration Workflow is Well-Documented
Process:- Develop locally with
supabase start - Create migrations with
supabase migration new - Test locally with
supabase db reset - Push to branch/project with
supabase db push - Generate types with
supabase gen types typescript
Script Testing Results
✅ Working Scripts
| Script | Status | Output |
|---|---|---|
lint-migrations.ts | ✅ Working | Parses 393 migration files |
generate-migration-reports.ts | ✅ Working | Generates audit reports |
count-tables-by-module.ts | ✅ Working | Counts 465 tables across 9 modules |
⏳ Needs Database Connection
| Script | Status | Requirement |
|---|---|---|
generate-types.sh | ⏳ Pending | Needs Supabase project ID |
| SQL audit scripts | ⏳ Pending | Needs database connection |
Current Database State
Table Inventory
| Module | Tables | Status |
|---|---|---|
| PF (Platform) | 74 | ✅ Complete |
| HR (Workforce) | 94 | ✅ Complete |
| FA (Finance) | 46 | ✅ Complete |
| FW (Forms) | 54 | ✅ Complete |
| RH (Recovery Housing) | 51 | ✅ Complete |
| GR (Governance) | 49 | ✅ Complete |
| FM (Facilities) | 22 | ✅ Complete |
| LO (Leadership OS) | 29 | ✅ Complete |
| IT (IT Operations) | 35 | ✅ Complete |
| Other | 11 | ✅ Complete |
| Total | 465 | ✅ Complete |
Migration Status
- Total Migrations: 393 files
- Chronological Order: ✅ Valid
- RLS Enabled: ✅ 467 tables
- SECURITY DEFINER Functions: ✅ 599 functions
- Update Triggers: ✅ 671 triggers
- Custom Fields: ✅ 363 tables
Critical Issues (P0)
1. RLS UPDATE Policies Missing WITH CHECK
Count: 118 policiesRisk: Users could modify
organization_id, enabling cross-tenant data leakageFix: Migration script ready (from audit output)
2. TypeScript Types Empty
Status:src/integrations/supabase/types.ts has no table definitionsFix: Run
./scripts/generate-types.sh after migration
High Priority Issues (P1)
1. Storage Bucket Naming
Count: 4 non-compliant bucketsFix: Rename migration ready (from audit output)
2. Missing Audit Columns
Count: ~60 tables missingupdated_by (where created_by exists)Fix: ADD COLUMN migration ready (from audit output)
Next Steps
-
Set Up Staging Branch
- Create persistent branch:
staging - Apply all migrations
- Verify table counts
- Create persistent branch:
-
Run SQL Audits
- Execute
audit-rls-policies.sql - Execute
audit-table-columns.sql - Execute
audit-storage-buckets.sql - Save fix statement outputs
- Execute
-
Create Fix Migrations
- RLS WITH CHECK fixes
- Storage bucket renames
- Missing audit columns
-
Validate in Staging
- Apply fixes
- Re-run audits
- Generate types
- Test application
-
Production Migration
- Follow completion plan
- Execute during maintenance window
- Validate thoroughly
Documentation
- Completion Plan: COMPLETION_PLAN.md
- Staging Setup: STAGING_SETUP_GUIDE.md
- Migration Readiness: ../../reports/MIGRATION_READINESS_REPORT.md
Last Updated: 2026-01-15