-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sql
57 lines (50 loc) · 1.53 KB
/
setup.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
CREATE TABLE user (
id INTEGER NOT NULL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
username TEXT NOT NULL,
password_hash TEXT NOT NULL,
email_verified INTEGER NOT NULL DEFAULT 0,
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 email_verification_request (
id TEXT NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES user(id),
email TEXT NOT NULL,
code TEXT NOT NULL,
expires_at INTEGER NOT NULL
);
CREATE TABLE password_reset_session (
id TEXT NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES user(id),
email TEXT NOT NULL,
code TEXT NOT NULL,
expires_at INTEGER NOT NULL,
email_verified INTEGER NOT NULL NOT NULL DEFAULT 0,
two_factor_verified INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE totp_credential (
id INTEGER NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL UNIQUE REFERENCES user(id),
key BLOB NOT NULL
);
CREATE TABLE passkey_credential (
id BLOB NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES user(id),
name TEXT NOT NULL,
algorithm INTEGER NOT NULL,
public_key BLOB NOT NULL
);
CREATE TABLE security_key_credential (
id BLOB NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES user(id),
name TEXT NOT NULL,
algorithm INTEGER NOT NULL,
public_key BLOB NOT NULL
);