-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.sql
43 lines (38 loc) · 1.16 KB
/
schema.sql
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
CREATE TABLE user (
id INTEGER NOT NULL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
username TEXT NOT NULL,
password_hash TEXT NOT NULL,
totp_key BLOB,
recovery_code BLOB NOT NULL
);
CREATE INDEX email_index ON user(email);
CREATE TABLE session (
id TEXT NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES user(id),
expires_at INTEGER NOT NULL,
two_factor_verified INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE signup_session (
id TEXT NOT NULL PRIMARY KEY,
expires_at INTEGER NOT NULL,
email TEXT NOT NULL,
username TEXT NOT NULL,
password_hash TEXT NOT NULL,
email_verification_code TEXT NOT NULL
);
CREATE TABLE password_reset_session (
id TEXT NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES user(id),
expires_at INTEGER NOT NULL,
email TEXT NOT NULL,
email_verification_code_hash TEXT NOT NULL,
email_verified INTEGER NOT NULL NOT NULL DEFAULT 0,
two_factor_verified INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE session_email_verification_request (
session_id TEXT NOT NULL PRIMARY KEY,
expires_at INTEGER NOT NULL,
email TEXT NOT NULL,
code TEXT NOT NULL
);