Skip to main content

Database Schema

HostMetrics uses Supabase (PostgreSQL) with 25+ tables organized into four domains.

Core Tables

Investor Tables

Toll Tables

Billing Tables

Multi-Tenant Isolation

Every table includes a user_id column with Row Level Security (RLS) policies:
-- Example RLS policy (applied to all tables)
CREATE POLICY "Users can only see their own data"
    ON trips FOR ALL
    USING (user_id = auth.uid());
All application queries go through getCurrentUserId() in src/lib/db/_client.ts, which extracts the authenticated user’s ID from the Supabase session.