Database Schema
anymrkt uses Supabase Postgres with RLS enabled on all tables (deny-by-default). Migrations live in supabase/migrations/ — never edit supabase-schema.sql directly after setup.
RLS identity convention
Critical:
This app runs NextAuth v5 with the Supabase adapter, not Supabase Auth. Therefore RLS policies must use next_auth.uid(), never auth.uid(). The auth.uid() function is always NULL here and a policy using it denies rather than permits. Role checks use is_operator(), never auth.jwt() -> 'role'.
Key tables
| Table | Purpose |
|---|---|
| profiles | User profiles; role column (buyer, seller_pending, seller_active, operator). |
| brands | Marketplace brands; multi-tenant scoping. |
| mcp_tokens | MCP bearer tokens; includes tool_filters JSONB column. |
| mcp_operations | Audit log for every MCP tool call. |
| listings | Product listings on the marketplace. |
| builder_pages | Builder pages with standalone flag for export. |