prisma-starter/prisma/migrations/20210924101547_add_profile/migration.sql

21 lines
798 B
MySQL
Raw Normal View History

2021-09-24 17:24:41 +07:00
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Profile" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"bio" TEXT NOT NULL,
"avatar" TEXT,
"userId" INTEGER NOT NULL,
"enabled" BOOLEAN NOT NULL DEFAULT true,
CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Profile" ("avatar", "bio", "enabled", "id", "userId") SELECT "avatar", "bio", "enabled", "id", "userId" FROM "Profile";
DROP TABLE "Profile";
ALTER TABLE "new_Profile" RENAME TO "Profile";
CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
-- RedefineIndex
DROP INDEX "User.email_unique";
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");