Skip to content

Clean up Supabase & Track Schemas

Great question. To perform a clean sweep of your Supabase schema and understand what’s already implemented—including automations, triggers, tables, and views—you can run introspective SQL queries directly from the Supabase SQL Editor or psql interface. Here’s how to approach this systematically:

1. List All Tables in the Current Schema

sql
CopyEdit
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public' AND table_type = 'BASE TABLE';

This will return all tables, including holons, simulations, proposals, votes, etc.

2. List All Views (Optional Insight into Derived Data)

sql
CopyEdit
SELECT table_name
FROM information_schema.views
WHERE table_schema = 'public';

3. List All Functions (Includes Edge/Trigger Logic If Defined in SQL)

sql
CopyEdit
SELECT routine_name
FROM information_schema.routines
WHERE routine_schema = 'public';

This will help you trace any custom logic, including SQL-based edge functions.

4. List All Triggers in the System

sql
CopyEdit
SELECT event_object_table AS table_name,
trigger_name,
action_timing,
event_manipulation AS event,
action_statement
FROM information_schema.triggers
WHERE trigger_schema = 'public';

This identifies what automations are live at the database level—especially relevant for items like auto-close proposals or feedback escalation.

5. Check for Automations Stored in the automations Table

If you're storing logic descriptions as JSON or structured metadata:
sql
CopyEdit
SELECT id, trigger_type, action_type, config, enabled, created_at
FROM automations
ORDER BY created_at DESC;

This gives you a snapshot of your full automation configuration layer, similar to a registry.

Optional: Query Row-Level Security (RLS) Policies

sql
CopyEdit
SELECT table_name, policy_name, command, using_expression
FROM pg_policies
WHERE schemaname = 'public';

Helpful if your automations or access logic depend on RLS.

🔁 How to Cross-Reference With Lovable

While Supabase gives full visibility into schema logic, Lovable’s frontend interface may hide or abstract automation toggles or conditionals. To cross-check:
Open the Lovable canvas (admin side)
Search for components or cards using:
Keywords like “simulation,” “resource,” or “feedback”
Or inspect any modules that display triggers, webhooks, or webhook-triggered updates
If using custom commands or n8n, check integrations tied to Supabase events (usually via Make or webhooks)

✨ Optional Automation Audit Tool (Future Idea)

You could eventually build a Holonic Audit Dashboard that lists:
Table 7
Automation Name
Trigger Table
Condition
Action Summary
Enabled
Proposal Auto-Close
proposals
deadline < now()
Approve or reject based on votes
Simulation Escalation
simulations
Needs Adjustment
Spawn proposal, alert holon lead
There are no rows in this table
This could be auto-generated from the automations table or from trigger metadata.
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.