Spaces:
Sleeping
Supabase Migration Complete β
After running the migration, your data is now in Supabase. This document explains how to ensure all future data is saved to Supabase instead of SQLite.
β What's Already Configured
Both RulesStore and AnalyticsStore automatically detect and use Supabase when credentials are available. They will:
- Check for Supabase credentials in your
.envfile - Use Supabase if available (preferred)
- Fall back to SQLite only if Supabase is not configured
π§ Required Configuration
To ensure Supabase is used for all future data, make sure your .env file has:
# Required for runtime (REST API)
SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_SERVICE_KEY=your_service_role_key_here
# Optional: For direct PostgreSQL connection (migration only)
POSTGRESQL_URL=postgresql://postgres:password@db.xxxxx.supabase.co:5432/postgres
Important:
SUPABASE_URLandSUPABASE_SERVICE_KEYare required for runtimePOSTGRESQL_URLis optional (only needed for migration script)- Both stores use the Supabase REST API at runtime, not direct PostgreSQL
β Verify Configuration
Run the verification script to confirm Supabase is configured:
python verify_supabase_setup.py
This will show:
- β Which backend each store is using
- β οΈ Any missing configuration
- π Summary of what will be saved where
π After Configuration
Restart your services:
# Stop your FastAPI server # Stop your MCP server # Then restart themCheck startup logs: You should see messages like:
β RulesStore: Using Supabase backend β AnalyticsStore: Using Supabase backend β AgentOrchestrator Analytics: Using Supabase backendTest by adding data:
- Add a rule via the admin panel
- Make a query to generate analytics
- Check Supabase Dashboard β Table Editor to verify data appears
π Where Data is Saved
| Data Type | Storage Location | Configuration |
|---|---|---|
| Admin Rules | Supabase admin_rules table |
SUPABASE_URL + SUPABASE_SERVICE_KEY |
| Analytics Events | Supabase analytics tables | SUPABASE_URL + SUPABASE_SERVICE_KEY |
| Tool Usage | Supabase tool_usage_events |
SUPABASE_URL + SUPABASE_SERVICE_KEY |
| Red Flags | Supabase redflag_violations |
SUPABASE_URL + SUPABASE_SERVICE_KEY |
| RAG Searches | Supabase rag_search_events |
SUPABASE_URL + SUPABASE_SERVICE_KEY |
| Agent Queries | Supabase agent_query_events |
SUPABASE_URL + SUPABASE_SERVICE_KEY |
π Troubleshooting
Data still going to SQLite?
Check your
.envfile:# Make sure these are set (no quotes, no spaces) SUPABASE_URL=https://xxxxx.supabase.co SUPABASE_SERVICE_KEY=eyJ... (full key)Verify credentials:
python verify_supabase_key.pyCheck startup logs: Look for warnings like:
β οΈ RulesStore: Using SQLite backendThis means Supabase credentials are missing or invalid.
Restart services: Environment variables are loaded at startup. After changing
.env, restart your services.
Tables don't exist?
If you see errors about missing tables:
- Go to Supabase Dashboard β SQL Editor
- Run
supabase_admin_rules_table.sql(for rules) - Run
supabase_analytics_tables.sql(for analytics)
API Key errors?
- Make sure you're using the service_role key (not anon key)
- Key should be ~200+ characters long
- No quotes or spaces around the value in
.env
π Summary
β
Migration complete - Your existing data is in Supabase
β
Auto-detection enabled - Stores automatically use Supabase when configured
β
Startup logging - You'll see which backend is being used
β
Verification script - Run verify_supabase_setup.py to check configuration
Next time you add rules or generate analytics, they will automatically be saved to Supabase! π