From 09a72a7e1a0ba5bcd172e66890050f0d9a461332 Mon Sep 17 00:00:00 2001 From: Shayne Czyzewski Date: Fri, 11 Feb 2022 17:55:41 -0500 Subject: [PATCH] Upgrade Prisma to version 3.9.1 (#452) --- .../migration.sql | 26 +++++++++++++++++++ .../migration.sql | 20 ++++++++++++++ .../migration.sql | 18 +++++++++++++ waspc/src/Wasp/Generator/Common.hs | 2 +- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 examples/realworld/migrations/20220207203326_upgrade_prisma_to_3_9_1/migration.sql create mode 100644 examples/waspello/migrations/20220211211659_upgrade_prisma_to_3_9_1/migration.sql create mode 100644 waspc/examples/todoApp/migrations/20220207202502_upgrade_prisma_to_3_9_1/migration.sql diff --git a/examples/realworld/migrations/20220207203326_upgrade_prisma_to_3_9_1/migration.sql b/examples/realworld/migrations/20220207203326_upgrade_prisma_to_3_9_1/migration.sql new file mode 100644 index 000000000..789825e22 --- /dev/null +++ b/examples/realworld/migrations/20220207203326_upgrade_prisma_to_3_9_1/migration.sql @@ -0,0 +1,26 @@ +-- DropForeignKey +ALTER TABLE "Article" DROP CONSTRAINT "Article_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Comment" DROP CONSTRAINT "Comment_articleId_fkey"; + +-- DropForeignKey +ALTER TABLE "Comment" DROP CONSTRAINT "Comment_userId_fkey"; + +-- AddForeignKey +ALTER TABLE "Article" ADD CONSTRAINT "Article_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- RenameIndex +ALTER INDEX "Article.slug_unique" RENAME TO "Article_slug_key"; + +-- RenameIndex +ALTER INDEX "User.email_unique" RENAME TO "User_email_key"; + +-- RenameIndex +ALTER INDEX "User.username_unique" RENAME TO "User_username_key"; diff --git a/examples/waspello/migrations/20220211211659_upgrade_prisma_to_3_9_1/migration.sql b/examples/waspello/migrations/20220211211659_upgrade_prisma_to_3_9_1/migration.sql new file mode 100644 index 000000000..893fbabf5 --- /dev/null +++ b/examples/waspello/migrations/20220211211659_upgrade_prisma_to_3_9_1/migration.sql @@ -0,0 +1,20 @@ +-- DropForeignKey +ALTER TABLE "Card" DROP CONSTRAINT "Card_authorId_fkey"; + +-- DropForeignKey +ALTER TABLE "Card" DROP CONSTRAINT "Card_listId_fkey"; + +-- DropForeignKey +ALTER TABLE "List" DROP CONSTRAINT "List_userId_fkey"; + +-- AddForeignKey +ALTER TABLE "List" ADD CONSTRAINT "List_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Card" ADD CONSTRAINT "Card_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Card" ADD CONSTRAINT "Card_listId_fkey" FOREIGN KEY ("listId") REFERENCES "List"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- RenameIndex +ALTER INDEX "User.email_unique" RENAME TO "User_email_key"; diff --git a/waspc/examples/todoApp/migrations/20220207202502_upgrade_prisma_to_3_9_1/migration.sql b/waspc/examples/todoApp/migrations/20220207202502_upgrade_prisma_to_3_9_1/migration.sql new file mode 100644 index 000000000..3ce0c8dad --- /dev/null +++ b/waspc/examples/todoApp/migrations/20220207202502_upgrade_prisma_to_3_9_1/migration.sql @@ -0,0 +1,18 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Task" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "description" TEXT NOT NULL, + "isDone" BOOLEAN NOT NULL DEFAULT false, + "userId" INTEGER NOT NULL, + CONSTRAINT "Task_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_Task" ("description", "id", "isDone", "userId") SELECT "description", "id", "isDone", "userId" FROM "Task"; +DROP TABLE "Task"; +ALTER TABLE "new_Task" RENAME TO "Task"; +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; + +-- RedefineIndex +DROP INDEX "User.email_unique"; +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/waspc/src/Wasp/Generator/Common.hs b/waspc/src/Wasp/Generator/Common.hs index f32e589ea..220904638 100644 --- a/waspc/src/Wasp/Generator/Common.hs +++ b/waspc/src/Wasp/Generator/Common.hs @@ -22,4 +22,4 @@ nodeVersionAsText = printf "%d.%d.%d" major minor patch (major, minor, patch) = nodeVersion prismaVersion :: String -prismaVersion = "2.22.1" +prismaVersion = "3.9.1"