1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-04 15:17:28 +02:00

Add SQLite schema for new tables 'users_2fa' and 'users_otps'

This commit is contained in:
Marco
2024-04-04 18:48:51 +02:00
parent 8f249d0080
commit 4d92ca24c2

View File

@@ -19,6 +19,16 @@ CREATE TABLE "users" (
CONSTRAINT "email" UNIQUE ("email") 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" ( CREATE TABLE "users_confirmations" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0), "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0),
"user_id" INTEGER NOT NULL CHECK ("user_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.email_expires" ON "users_confirmations" ("email", "expires");
CREATE INDEX "users_confirmations.user_id" ON "users_confirmations" ("user_id"); 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" ( CREATE TABLE "users_remembered" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0), "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK ("id" >= 0),
"user" INTEGER NOT NULL CHECK ("user" >= 0), "user" INTEGER NOT NULL CHECK ("user" >= 0),