forked from InvolutionHell/involutionhell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextauth_schema.sql
More file actions
43 lines (38 loc) · 1.18 KB
/
Copy pathnextauth_schema.sql
File metadata and controls
43 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- NextAuth required tables for Neon/Postgres
-- Run once (e.g. via psql) before enabling the Neon adapter.
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
email VARCHAR(255) UNIQUE,
"emailVerified" TIMESTAMPTZ,
image TEXT
);
CREATE TABLE IF NOT EXISTS accounts (
id SERIAL PRIMARY KEY,
"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,
refresh_token TEXT,
access_token TEXT,
expires_at BIGINT,
id_token TEXT,
scope TEXT,
session_state TEXT,
token_type TEXT,
UNIQUE("providerAccountId", provider)
);
CREATE TABLE IF NOT EXISTS sessions (
id SERIAL PRIMARY KEY,
"userId" INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
expires TIMESTAMPTZ NOT NULL,
"sessionToken" VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE IF NOT EXISTS verification_token (
identifier TEXT NOT NULL,
token TEXT NOT NULL,
expires TIMESTAMPTZ NOT NULL,
PRIMARY KEY (identifier, token)
);
CREATE INDEX IF NOT EXISTS "accounts_userId_idx" ON accounts("userId");
CREATE INDEX IF NOT EXISTS "sessions_userId_idx" ON sessions("userId");