2023-09-06 22:20:09 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS users
|
|
|
|
(
|
|
|
|
subject TEXT PRIMARY KEY UNIQUE NOT NULL,
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
username TEXT UNIQUE NOT NULL,
|
|
|
|
password TEXT NOT NULL,
|
2023-09-07 11:45:16 +01:00
|
|
|
picture TEXT DEFAULT "" NOT NULL,
|
|
|
|
website TEXT DEFAULT "" NOT NULL,
|
2023-09-06 22:20:09 +01:00
|
|
|
email TEXT NOT NULL,
|
|
|
|
email_verified INTEGER DEFAULT 0 NOT NULL,
|
|
|
|
pronouns TEXT DEFAULT "they/them" NOT NULL,
|
|
|
|
birthdate DATE,
|
2023-09-07 11:45:16 +01:00
|
|
|
zoneinfo TEXT DEFAULT "UTC" NOT NULL,
|
2023-09-06 22:20:09 +01:00
|
|
|
locale TEXT DEFAULT "en-US" NOT NULL,
|
2023-09-15 13:06:31 +01:00
|
|
|
role INTEGER DEFAULT 0 NOT NULL,
|
2023-09-06 22:20:09 +01:00
|
|
|
updated_at DATETIME,
|
2023-10-10 18:06:43 +01:00
|
|
|
registered INTEGER DEFAULT 0,
|
2023-09-06 22:20:09 +01:00
|
|
|
active INTEGER DEFAULT 1
|
|
|
|
);
|
|
|
|
|
2023-09-09 01:38:10 +01:00
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS username_index ON users (username);
|
|
|
|
|
2023-09-06 22:20:09 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS client_store
|
|
|
|
(
|
|
|
|
subject TEXT PRIMARY KEY UNIQUE NOT NULL,
|
2023-09-15 13:06:31 +01:00
|
|
|
name TEXT NOT NULL,
|
2023-09-06 22:20:09 +01:00
|
|
|
secret TEXT UNIQUE NOT NULL,
|
|
|
|
domain TEXT NOT NULL,
|
2023-09-15 13:06:31 +01:00
|
|
|
owner TEXT NOT NULL,
|
2023-09-06 22:20:09 +01:00
|
|
|
sso INTEGER,
|
2023-09-15 13:06:31 +01:00
|
|
|
active INTEGER DEFAULT 1,
|
|
|
|
FOREIGN KEY (owner) REFERENCES users (subject)
|
2023-09-06 22:20:09 +01:00
|
|
|
);
|
2023-09-09 01:38:10 +01:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS otp
|
|
|
|
(
|
|
|
|
subject TEXT PRIMARY KEY UNIQUE NOT NULL,
|
2023-10-16 16:47:18 +01:00
|
|
|
secret TEXT NOT NULL,
|
|
|
|
digits INTEGER NOT NULL,
|
2023-09-09 01:38:10 +01:00
|
|
|
FOREIGN KEY (subject) REFERENCES users (subject)
|
|
|
|
);
|