-- CreateTable
CREATE TABLE "User" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "username" TEXT NOT NULL,
    "password" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- CreateTable
CREATE TABLE "LoginAttempt" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "userId" INTEGER,
    "username" TEXT NOT NULL,
    "success" BOOLEAN NOT NULL,
    "enteredPassword" TEXT,
    "className" TEXT,
    "loginDurationMs" INTEGER,
    "passwordLength" INTEGER,
    "passwordPolicyViolation" BOOLEAN NOT NULL DEFAULT false,
    "passwordHasUpper" BOOLEAN NOT NULL DEFAULT false,
    "passwordHasLower" BOOLEAN NOT NULL DEFAULT false,
    "passwordHasDigit" BOOLEAN NOT NULL DEFAULT false,
    "passwordHasSpecial" BOOLEAN NOT NULL DEFAULT false,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT "LoginAttempt_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);

-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

-- CreateIndex
CREATE INDEX "LoginAttempt_createdAt_idx" ON "LoginAttempt"("createdAt");

-- CreateIndex
CREATE INDEX "LoginAttempt_username_idx" ON "LoginAttempt"("username");

-- CreateIndex
CREATE INDEX "LoginAttempt_className_idx" ON "LoginAttempt"("className");
