tulip/database/migrations/20240309221547_init.up.sql

43 lines
1.6 KiB
MySQL
Raw Normal View History

2024-03-11 12:39:52 +00:00
CREATE TABLE users
2023-09-06 22:20:09 +01:00
(
subject TEXT PRIMARY KEY UNIQUE NOT NULL,
name TEXT NOT NULL,
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
2024-03-11 12:39:52 +00:00
picture TEXT DEFAULT '' NOT NULL,
website TEXT DEFAULT '' NOT NULL,
2023-09-06 22:20:09 +01:00
email TEXT NOT NULL,
2024-03-11 12:39:52 +00:00
email_verified BOOLEAN DEFAULT 0 NOT NULL,
pronouns TEXT DEFAULT 'they/them' NOT NULL,
2023-09-06 22:20:09 +01:00
birthdate DATE,
2024-03-11 12:39:52 +00:00
zoneinfo TEXT DEFAULT 'UTC' NOT NULL,
locale TEXT DEFAULT 'en-US' NOT NULL,
role INTEGER DEFAULT 0 NOT NULL,
2024-03-11 12:39:52 +00:00
updated_at DATETIME NOT NULL,
registered DATETIME NOT NULL,
active BOOLEAN DEFAULT 1 NOT NULL
2023-09-06 22:20:09 +01:00
);
2024-03-11 12:39:52 +00:00
CREATE UNIQUE INDEX username_index ON users (username);
2024-03-11 12:39:52 +00:00
CREATE TABLE client_store
2023-09-06 22:20:09 +01:00
(
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,
2024-03-11 12:39:52 +00:00
public BOOLEAN NOT NULL,
sso BOOLEAN NOT NULL,
active BOOLEAN DEFAULT 1 NOT NULL,
FOREIGN KEY (owner) REFERENCES users (subject)
2023-09-06 22:20:09 +01:00
);
2024-03-11 12:39:52 +00:00
CREATE TABLE 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)
);