tulip/database/init.sql

42 lines
1.5 KiB
MySQL
Raw Normal View History

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,
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,
zoneinfo TEXT DEFAULT "UTC" NOT NULL,
2023-09-06 22:20:09 +01:00
locale TEXT DEFAULT "en-US" NOT NULL,
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
);
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,
name TEXT NOT NULL,
2023-09-06 22:20:09 +01:00
secret TEXT UNIQUE NOT NULL,
domain TEXT NOT NULL,
owner TEXT NOT NULL,
2023-09-06 22:20:09 +01:00
sso INTEGER,
active INTEGER DEFAULT 1,
FOREIGN KEY (owner) REFERENCES users (subject)
2023-09-06 22:20:09 +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,
FOREIGN KEY (subject) REFERENCES users (subject)
);