mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-08-19 21:00:19 +02:00
32 lines
1.3 KiB
MySQL
32 lines
1.3 KiB
MySQL
|
-- CreateTable
|
||
|
CREATE TABLE "OAuthUser" (
|
||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||
|
"provider" TEXT NOT NULL,
|
||
|
"providerUserId" TEXT NOT NULL,
|
||
|
"providerUsername" TEXT NOT NULL,
|
||
|
"userId" TEXT NOT NULL,
|
||
|
CONSTRAINT "OAuthUser_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,
|
||
|
"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", "totpEnabled", "totpSecret", "totpVerified", "updatedAt", "username") SELECT "createdAt", "email", "id", "isAdmin", "password", "totpEnabled", "totpSecret", "totpVerified", "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;
|