-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
37 lines (34 loc) · 1.19 KB
/
Copy pathschema.sql
File metadata and controls
37 lines (34 loc) · 1.19 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
CREATE TABLE clients (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
client_id UUID NOT NULL UNIQUE,
client_secret VARCHAR(255) NOT NULL,
redirect_uri VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE auth_codes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
code VARCHAR(255) NOT NULL UNIQUE,
scope VARCHAR(255) NOT NULL,
expires_at TIMESTAMP NOT NULL,
is_used BOOLEAN DEFAULT false
);
CREATE TABLE tokens (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
access_token TEXT NOT NULL,
refresh_token TEXT NOT NULL,
client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
scope VARCHAR(255) NOT NULL,
access_token_expires_at TIMESTAMP NOT NULL,
refresh_token_expires_at TIMESTAMP NOT NULL,
is_revoked BOOLEAN DEFAULT false
);