Operations

Supabase setup

Connect the app to Supabase Auth and run the consumption schema so dashboards and APIs resolve without schema errors.

Project variables

In Vercel (and .env.local), set:

  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY

Consumption migration

  1. Open Supabase → SQL Editor → New query.
  2. Copy the full contents of supabase/migrations/20260328120000_consumption.sql from the repository.
  3. Run the script. You should see success (no rows returned for DDL).

What it creates

  • Tables: usage_events, provider_connections, user_consumption_settings
  • Row Level Security policies scoped to auth.uid()
  • Function: public.get_consumption_dashboard() (no arguments)
  • Grant: EXECUTE for role authenticated

Verify

select public.get_consumption_dashboard();

Run as an authenticated user in SQL is not the same as JWT; in the app, the RPC runs with the user's JWT. If the dashboard loads without “schema cache” errors, you are aligned.

If PostgREST still reports a missing function immediately after creation, wait a short time or redeploy; caches usually refresh quickly.