mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-11-05 23:40:12 +01:00
32 lines
1.2 KiB
MySQL
32 lines
1.2 KiB
MySQL
|
-- CreateTable
|
||
|
CREATE TABLE "LoginToken" (
|
||
|
"token" TEXT NOT NULL PRIMARY KEY,
|
||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"expiresAt" DATETIME NOT NULL,
|
||
|
"userId" TEXT NOT NULL,
|
||
|
"used" BOOLEAN NOT NULL DEFAULT false,
|
||
|
CONSTRAINT "LoginToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||
|
);
|
||
|
|
||
|
-- RedefineTables
|
||
|
PRAGMA foreign_keys=OFF;
|
||
|
CREATE TABLE "new_User" (
|
||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" DATETIME NOT NULL,
|
||
|
"username" TEXT NOT NULL,
|
||
|
"email" TEXT NOT NULL,
|
||
|
"password" TEXT NOT NULL,
|
||
|
"isAdmin" BOOLEAN NOT NULL DEFAULT false,
|
||
|
"totpEnabled" BOOLEAN NOT NULL DEFAULT false,
|
||
|
"totpVerified" BOOLEAN NOT NULL DEFAULT false,
|
||
|
"totpSecret" TEXT
|
||
|
);
|
||
|
INSERT INTO "new_User" ("createdAt", "email", "id", "isAdmin", "password", "updatedAt", "username") SELECT "createdAt", "email", "id", "isAdmin", "password", "updatedAt", "username" FROM "User";
|
||
|
DROP TABLE "User";
|
||
|
ALTER TABLE "new_User" RENAME TO "User";
|
||
|
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||
|
PRAGMA foreign_key_check;
|
||
|
PRAGMA foreign_keys=ON;
|