Quick Start — Supabase
1. Create a Supabase Project
Section titled “1. Create a Supabase Project”If you don’t have one, create a project at supabase.com. Note your project’s database connection string and service role key.
2. Generate and Apply the SQL
Section titled “2. Generate and Apply the SQL”npm run build:supabaseOpen your Supabase project → SQL Editor → paste the contents of output/SMTA-supabase-<timestamp>.sql and run it.
Alternatively, apply via psql:
psql "$DATABASE_URL" -f output/SMTA-supabase-<timestamp>.sql3. What the Supabase Adapter Provides
Section titled “3. What the Supabase Adapter Provides”The Supabase deployment includes three adapter-specific files on top of @smta/core:
| File | Purpose |
|---|---|
auth_supabase_impl.sql | Implements core.get_current_user_id() using Supabase’s JWT (auth.uid()) |
secrets_supabase_impl.sql | Implements core.store_secret_impl() and core.delete_secret_impl() using Supabase Vault |
constraints.sql | Restores foreign keys from SMTA tables to auth.users |
4. Verify
Section titled “4. Verify”In the SQL Editor, call a public function to confirm everything is working:
-- Should return an empty array (no orgs yet)select public.list_my_organizations();If the function exists and returns without error, SMTA is deployed.
5. Add Your App Schema
Section titled “5. Add Your App Schema”Create your app schema tables on top of SMTA. SMTA’s RLS policies gate visibility by org/unit membership — your tables reference core.organizations or core.units as needed.
create schema if not exists app;
create table app.projects ( id uuid primary key default gen_random_uuid(), org_id uuid not null references core.organizations(id), name text not null, created_at timestamptz default now());
-- Enable RLSalter table app.projects enable row level security;
-- Only members of the org can see the projectcreate policy "org members" on app.projects for all using ( exists ( select 1 from core.memberships m where m.organization_id = app.projects.org_id and m.user_id = core.get_current_user_id() and m.is_deleted = false ) );