diff --git a/docs/pages/getting-started/adapters/pg.mdx b/docs/pages/getting-started/adapters/pg.mdx index 80ef5199f2..5558c945a4 100644 --- a/docs/pages/getting-started/adapters/pg.mdx +++ b/docs/pages/getting-started/adapters/pg.mdx @@ -202,19 +202,21 @@ The SQL schema for the tables used by this adapter is as follows. Learn more abo doc page on [Database Models](/guides/creating-a-database-adapter). ```sql -CREATE TABLE verification_token +CREATE TABLE users ( - identifier TEXT NOT NULL, - expires TIMESTAMPTZ NOT NULL, - token TEXT NOT NULL, + id SERIAL, + name VARCHAR(255), + email VARCHAR(255) UNIQUE, + "emailVerified" TIMESTAMPTZ, + image TEXT, - PRIMARY KEY (identifier, token) + PRIMARY KEY (id) ); CREATE TABLE accounts ( id SERIAL, - "userId" INTEGER NOT NULL, + "userId" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, type VARCHAR(255) NOT NULL, provider VARCHAR(255) NOT NULL, "providerAccountId" VARCHAR(255) NOT NULL, @@ -232,22 +234,20 @@ CREATE TABLE accounts CREATE TABLE sessions ( id SERIAL, - "userId" INTEGER NOT NULL, + "userId" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, expires TIMESTAMPTZ NOT NULL, - "sessionToken" VARCHAR(255) NOT NULL, + "sessionToken" VARCHAR(255) UNIQUE NOT NULL, PRIMARY KEY (id) ); -CREATE TABLE users +CREATE TABLE verification_token ( - id SERIAL, - name VARCHAR(255), - email VARCHAR(255), - "emailVerified" TIMESTAMPTZ, - image TEXT, + identifier TEXT NOT NULL, + expires TIMESTAMPTZ NOT NULL, + token TEXT NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (identifier, token) ); ``` diff --git a/docs/pages/getting-started/providers/apple.mdx b/docs/pages/getting-started/providers/apple.mdx index 1fbb0db8d1..e881ad717a 100644 --- a/docs/pages/getting-started/providers/apple.mdx +++ b/docs/pages/getting-started/providers/apple.mdx @@ -10,7 +10,7 @@ import { Code } from "@/components/Code" - Sign in with Apple [REST API](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api) - [How to retrieve](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple#3383773) the user's information from Apple ID servers -> **_NOTE:_** Apple currently does not support [RedirectProxyUrl](https://github.com/nextauthjs/next-auth/blob/3ec06842682a31e53fceabca701a362abda1e7dd/packages/core/src/lib/utils/providers.ts#L48) usage. +> **_NOTE:_** Apple currently does not support [RedirectProxyUrl](https://github.com/nextauthjs/next-auth/blob/3ec06842682a31e53fceabca701a362abda1e7dd/packages/core/src/lib/utils/providers.ts#L48) usage. ## Setup diff --git a/packages/adapter-pg/schema.sql b/packages/adapter-pg/schema.sql index d1bd429c2e..cae70d49a7 100644 --- a/packages/adapter-pg/schema.sql +++ b/packages/adapter-pg/schema.sql @@ -1,18 +1,20 @@ \set ON_ERROR_STOP true -CREATE TABLE verification_token +CREATE TABLE users ( - identifier TEXT NOT NULL, - expires TIMESTAMPTZ NOT NULL, - token TEXT NOT NULL, - - PRIMARY KEY (identifier, token) + id SERIAL, + name VARCHAR(255), + email VARCHAR(255) UNIQUE, + "emailVerified" TIMESTAMPTZ, + image TEXT, + + PRIMARY KEY (id) ); CREATE TABLE accounts ( id SERIAL, - "userId" INTEGER NOT NULL, + "userId" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, type VARCHAR(255) NOT NULL, provider VARCHAR(255) NOT NULL, "providerAccountId" VARCHAR(255) NOT NULL, @@ -23,27 +25,25 @@ CREATE TABLE accounts scope TEXT, session_state TEXT, token_type TEXT, - + PRIMARY KEY (id) ); - + CREATE TABLE sessions ( id SERIAL, - "userId" INTEGER NOT NULL, + "userId" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, expires TIMESTAMPTZ NOT NULL, - "sessionToken" VARCHAR(255) NOT NULL, - + "sessionToken" VARCHAR(255) UNIQUE NOT NULL, + PRIMARY KEY (id) ); -CREATE TABLE users +CREATE TABLE verification_token ( - id SERIAL, - name VARCHAR(255), - email VARCHAR(255), - "emailVerified" TIMESTAMPTZ, - image TEXT, - - PRIMARY KEY (id) + identifier TEXT NOT NULL, + expires TIMESTAMPTZ NOT NULL, + token TEXT NOT NULL, + + PRIMARY KEY (identifier, token) );