Skip to content

Supabase DB Verification Report

Date: 2026-02-16 Status: ✅ All migrations verified and matching DB state.

1. Public Tables & RLS Status

All tables in the public schema have Row Level Security (RLS) enabled.

Table RLS Enabled Policies Count Primary Key
documents 1 id
chunks 1 id
usage_logs 1 id
profiles 1 user_id
wallet 1 user_id
wallet_ledger 1 id
scrape_runs 1 id
references 1 id
personas 1 id

2. RLS Policies Verification

Policies are strictly defined to allow users to see only their own data or restrict access to service_role/postgres only.

Table Policy Name Roles Command Definition
documents Admin can manage documents service_role, postgres ALL true
chunks Admin can manage chunks service_role, postgres ALL true
scrape_runs Admin can manage scrape_runs service_role, postgres ALL true
references Admin can manage references service_role, postgres ALL true
personas Admin can manage personas service_role, postgres ALL true
profiles Users can view own profile public SELECT auth.uid() = user_id
wallet Users can view own wallet public SELECT auth.uid() = user_id
wallet_ledger Users can view own ledger public SELECT auth.uid() = user_id
usage_logs Users can view own logs public SELECT auth.uid()::text = user_id

3. Critical Functions & Triggers

Component Status Details
handle_new_user SECURITY DEFINER, search_path set to public, auth, extensions
on_auth_user_created Trigger on auth.users after INSERT, calling handle_new_user

4. Key Indexes

Verified that all critical foreign keys and frequently queried columns are indexed.

Table Index Name Columns
chunks idx_chunks_document_id document_id
scrape_runs idx_scrape_runs_triggered_by triggered_by_user_id
usage_logs idx_usage_logs_created_at created_at DESC
wallet_ledger idx_wallet_ledger_user_id_created_at user_id, created_at DESC
references references_source_pdf_source_key source, pdf_source (UNIQUE)

5. Drift Analysis

No drift detected between db/migrations/ and current Supabase production state. - Expected migrations: 0001 - 0011. - Applied: All.