The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add NextAuth quickstart snippet.
thorwebdevec4ad859be19
diff --git a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts b/studio/components/interfaces/SQLEditor/SQLEditor.constants.tsindex 246aabc8382..63ec9612ed2 100644--- a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts+++ b/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts@@ -97,7 +97,7 @@ language sql volatile;`.trim(),},{- id: 8,+ id: 9,type: 'template',title: 'pg_stat_statements report',description: 'Select from pg_stat_statements and view recent queries',@@ -130,7 +130,7 @@ select100;`,},{- id: 9,+ id: 10,type: 'quickstart',title: 'Countries',description: 'Create a table with all the countries in the world.',@@ -409,7 +409,7 @@ insert into public.countries (name,iso2,iso3,local_name,continent) values`.trim(),},{- id: 10,+ id: 11,type: 'quickstart',title: 'Slack Clone',description: 'Build a basic slack clone with Row Level Security.',@@ -606,7 +606,7 @@ values`.trim(),},{- id: 11,+ id: 12,type: 'quickstart',title: 'Todo List',description: 'Build a basic todo list with Row Level Security.',@@ -638,7 +638,7 @@ create policy "Individuals can delete their own todos." on todos for`.trim(),},{- id: 12,+ id: 13,type: 'quickstart',title: 'Stripe Subscriptions',description: 'Starter template for the Next.js Stripe Subscriptions Starter.',@@ -805,7 +805,7 @@ create publication supabase_realtime`.trim(),},{- id: 13,+ id: 14,type: 'quickstart',title: 'User Management Starter',description: 'Sets up a public Profiles table which you can access with your API.',@@ -860,6 +860,115 @@ create policy "Avatar images are publicly accessible." on storage.objectscreate policy "Anyone can upload an avatar." on storage.objectsfor insert with check (bucket_id = 'avatars');+`.trim(),+ },+ {+ id: 15,+ type: 'quickstart',+ title: 'NextAuth Schema Setup',+ description: 'Sets up a the Schema and Tables for the NextAuth Supabase Adapter.',+ sql: `+--+-- Name: next_auth; Type: SCHEMA;+--+CREATE SCHEMA next_auth;++GRANT USAGE ON SCHEMA next_auth TO service_role;+GRANT ALL ON SCHEMA next_auth TO postgres;++--+-- Create users table+--+CREATE TABLE IF NOT EXISTS next_auth.users+(+ id uuid NOT NULL DEFAULT uuid_generate_v4(),+ name text,+ email text,+ "emailVerified" timestamp with time zone,+ image text,+ CONSTRAINT users_pkey PRIMARY KEY (id),+ CONSTRAINT email_unique UNIQUE (email)+);++GRANT ALL ON TABLE next_auth.users TO postgres;+GRANT ALL ON TABLE next_auth.users TO service_role;++--- uid() function to be used in RLS policies+CREATE FUNCTION next_auth.uid() RETURNS uuid+ LANGUAGE sql STABLE+ AS $$+ select+ coalesce(+ nullif(current_setting('request.jwt.claim.sub', true), ''),+ (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub')+ )::uuid+$$;++--+-- Create sessions table+--+CREATE TABLE IF NOT EXISTS next_auth.sessions+(+ id uuid NOT NULL DEFAULT uuid_generate_v4(),+ expires timestamp with time zone NOT NULL,+ "sessionToken" text NOT NULL,+ "userId" uuid,+ CONSTRAINT sessions_pkey PRIMARY KEY (id),+ CONSTRAINT sessionToken_unique UNIQUE ("sessionToken"),+ CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId")+ REFERENCES next_auth.users (id) MATCH SIMPLE+ ON UPDATE NO ACTION+ ON DELETE CASCADE+);++GRANT ALL ON TABLE next_auth.sessions TO postgres;+GRANT ALL ON TABLE next_auth.sessions TO service_role;++--+-- Create accounts table+--+CREATE TABLE IF NOT EXISTS next_auth.accounts+(+ id uuid NOT NULL DEFAULT uuid_generate_v4(),+ type text NOT NULL,+ provider text NOT NULL,+ "providerAccountId" text NOT NULL,+ refresh_token text,+ access_token text,+ expires_at bigint,+ token_type text,+ scope text,+ id_token text,+ session_state text,+ oauth_token_secret text,+ oauth_token text,+ "userId" uuid,+ CONSTRAINT accounts_pkey PRIMARY KEY (id),+ CONSTRAINT provider_unique UNIQUE (provider, "providerAccountId"),+ CONSTRAINT "accounts_userId_fkey" FOREIGN KEY ("userId")+ REFERENCES next_auth.users (id) MATCH SIMPLE+ ON UPDATE NO ACTION+ ON DELETE CASCADE+);++GRANT ALL ON TABLE next_auth.accounts TO postgres;+GRANT ALL ON TABLE next_auth.accounts TO service_role;++--+-- Create verification_tokens table+--+CREATE TABLE IF NOT EXISTS next_auth.verification_tokens+(+ identifier text,+ token text,+ expires timestamp with time zone NOT NULL,+ CONSTRAINT verification_tokens_pkey PRIMARY KEY (token),+ CONSTRAINT token_unique UNIQUE (token),+ CONSTRAINT token_identifier_unique UNIQUE (token, identifier)+);++GRANT ALL ON TABLE next_auth.verification_tokens TO postgres;+GRANT ALL ON TABLE next_auth.verification_tokens TO service_role;`.trim(),},]