21 lines
798 B
MySQL
21 lines
798 B
MySQL
|
-- 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");
|