From 4d92ca24c2ba513f20427320d0e8131c1a57030d Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 4 Apr 2024 18:48:51 +0200 Subject: [PATCH] Add SQLite schema for new tables 'users_2fa' and 'users_otps' --- Database/SQLite.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Database/SQLite.sql b/Database/SQLite.sql index f505396..d0ab5c5 100644 --- a/Database/SQLite.sql +++ b/Database/SQLite.sql @@ -19,6 +19,16 @@ CREATE TABLE "users" ( CONSTRAINT "email" UNIQUE ("email") ); +CREATE TABLE "users_2fa" ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0), + "user_id" INTEGER NOT NULL CHECK ("user_id" >= 0), + "mechanism" INTEGER NOT NULL CHECK ("mechanism" >= 0), + "seed" VARCHAR(255) DEFAULT NULL, + "created_at" INTEGER NOT NULL CHECK ("created_at" >= 0), + "expires_at" INTEGER CHECK ("expires_at" >= 0) DEFAULT NULL, + CONSTRAINT "user_id_mechanism" UNIQUE ("user_id", "mechanism") +); + CREATE TABLE "users_confirmations" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0), "user_id" INTEGER NOT NULL CHECK ("user_id" >= 0), @@ -31,6 +41,18 @@ CREATE TABLE "users_confirmations" ( CREATE INDEX "users_confirmations.email_expires" ON "users_confirmations" ("email", "expires"); CREATE INDEX "users_confirmations.user_id" ON "users_confirmations" ("user_id"); +CREATE TABLE "users_otps" ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0), + "user_id" INTEGER NOT NULL CHECK ("user_id" >= 0), + "mechanism" INTEGER NOT NULL CHECK ("mechanism" >= 0), + "single_factor" INTEGER NOT NULL CHECK ("single_factor" >= 0) DEFAULT "0", + "selector" VARCHAR(24) NOT NULL, + "token" VARCHAR(255) NOT NULL, + "expires_at" INTEGER CHECK ("expires_at" >= 0) DEFAULT NULL +); +CREATE INDEX "users_otps.user_id_mechanism" ON "users_otps" ("user_id", "mechanism"); +CREATE INDEX "users_otps.selector_user_id" ON "users_otps" ("selector", "user_id"); + CREATE TABLE "users_remembered" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0), "user" INTEGER NOT NULL CHECK ("user" >= 0),