Documentation
Supabase Migration Deployment Guide
arxsec-app / migrations/DEPLOYMENT_INSTRUCTIONS.md
Quick Deploy (Recommended)
Step 1: Open Supabase Dashboard
- Go to https://app.supabase.com
- Click your project (
jdiyzjmdtzwtyanzzraz) - Navigate to SQL Editor (left sidebar)
Step 2: Create New Query
- Click New Query button
- Or click the + icon next to "New Query"
Step 3: Copy & Paste Migration Script
- Open this file:
migrations/deploy_all_migrations.sql - Copy ALL contents (Ctrl+A, Ctrl+C)
- Paste into the SQL Editor (Ctrl+V)
Step 4: Run Migrations
- Click the ▶ Run button (or Ctrl+Enter)
- Wait for completion (~5-10 seconds)
- You should see:
`` deployment_status: "Supabase migrations deployed successfully" tables_created: [number of tables] ``
Step 5: Verify Deployment
- Go to Database (left sidebar)
- Click Tables
- Look for:
- ✓
agents - ✓
drift_events - ✓
approval_requests - ✓
policies - ✓ And 30+ more tables
Alternative: Deploy via CLI
If you have Supabase CLI installed:
``bash cd /path/to/arxsec-app supabase db push --linked ``
Or push specific migrations:
``bash supabase db push migrations/001_initial_schema.sql --linked ``
What Gets Deployed
Core Tables (from 001_initial_schema.sql)
orgs- Organizationsusers- User accountsagents- AI agents with declared intentpolicies- Security policies for agent actionsapproval_requests- Manual approval tasksaudit_log- Complete action audit traildrift_events- Behavioral drift detectionscompliance_packages- Evidence for audits
Advanced Features
- SSO/SAML: sso_configs, sso_providers
- SCIM: scim_tokens, groups, group_members
- Encryption: encryption_configs (CMEK support)
- API Keys: api_keys, webhooks, webhook_deliveries
- Geordie Integration: Risk signal mappings
- LLM Providers: Multi-provider support with health checks
- Cloud Assets: Inventory tracking and dependencies
Security
- Row-Level Security (RLS) enabled on all org-scoped tables
- Encryption at rest for sensitive credentials
- Foreign key constraints for referential integrity
- Comprehensive indexes for performance
After Deployment
1. Verify Database Schema
``sql -- Run in SQL Editor to verify SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name; ``
2. Check Drift Events Table
```sql -- Should return 10 seeded drift events SELECT COUNT(*) as event_count FROM drift_events;
-- View sample events SELECT drift_type, severity, response_taken FROM drift_events LIMIT 5; ```
3. Refresh Dashboard
- Go to https://app.arxsec.io/governance/drift
- Page should refresh automatically
- Behavioral Drift Detection metrics should show:
- TOTAL EVENTS: 10
- CRITICAL: 2
- HIGH: 4
- RESOLVED: 0
- AGENTS SUSPENDED: 2
Troubleshooting
Error: "relation already exists"
Cause: Migrations were already deployed Fix: This is safe - all migrations use IF NOT EXISTS. You can re-run without issues.
Error: "permission denied"
Cause: Service role key doesn't have database permissions Fix:
- Go to Settings → API
- Copy fresh Service Role Key
- Re-run migrations
Error: "syntax error"
Cause: SQL was corrupted during copy-paste Fix:
- Go back to
deploy_all_migrations.sql - Re-copy the file (Ctrl+A, Ctrl+C)
- Clear editor and re-paste
- Run again
Dashboard still shows "No drift events"
Cause: Frontend cache or page not refreshed Fix:
- Hard refresh browser: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
- Or wait 30 seconds for cache to clear
- Verify migrations ran: SELECT COUNT(*) FROM drift_events;
Important Notes
Idempotent Migrations
All migrations use CREATE TABLE IF NOT EXISTS and ADD COLUMN IF NOT EXISTS, making them safe to re-run multiple times.
Schema Consolidation
This script excludes approval_mitl_schema.sql because it duplicates 013_approval_escalation_chain.sql. Both create identical org_hierarchy, approval_rules, and approval_notifications tables.
Row-Level Security
All tables with org_id automatically enforce organization-scoped access via RLS policies. Users can only see data from their organization.
Performance
The combined script includes strategic indexes on:
org_id(organization filtering)status(agent/request status)created_at(audit trail sorting)severity(drift event filtering)
Next Steps
After migrations are deployed:
- Deploy Edge Functions
``bash supabase functions deploy drift-check --linked supabase functions deploy approval-notify --linked supabase functions deploy on-signup --linked ``
- Configure Webhooks
- Database → Webhooks
- Add triggers for approval notifications and signup automation
- Set Scheduled Drift Detection
- Edge Functions → drift-check
- Enable scheduled execution at
0 * * * *(hourly)
Support
- Supabase Dashboard: https://app.supabase.com
- Documentation: https://supabase.com/docs
- Status: https://status.supabase.com
For questions about ARXsec-specific tables/functions, refer to:
docs/- Architecture documentation- GitHub Issues - Report problems or ask questions