From 11d10bee12c3f0e973b967342cf3a7fe44e17ebd Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 5 Sep 2022 09:09:49 +0200 Subject: [PATCH] migrate: database_branches --- .../migration.sql | 22 +++++++++++++++++++ apps/api/prisma/schema.prisma | 1 + 2 files changed, 23 insertions(+) create mode 100644 apps/api/prisma/migrations/20220905062318_database_branching/migration.sql diff --git a/apps/api/prisma/migrations/20220905062318_database_branching/migration.sql b/apps/api/prisma/migrations/20220905062318_database_branching/migration.sql new file mode 100644 index 000000000..d828a4c66 --- /dev/null +++ b/apps/api/prisma/migrations/20220905062318_database_branching/migration.sql @@ -0,0 +1,22 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_ApplicationSettings" ( + "id" TEXT NOT NULL PRIMARY KEY, + "applicationId" TEXT NOT NULL, + "dualCerts" BOOLEAN NOT NULL DEFAULT false, + "debug" BOOLEAN NOT NULL DEFAULT false, + "previews" BOOLEAN NOT NULL DEFAULT false, + "autodeploy" BOOLEAN NOT NULL DEFAULT true, + "isBot" BOOLEAN NOT NULL DEFAULT false, + "isPublicRepository" BOOLEAN NOT NULL DEFAULT false, + "isDBBranching" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "ApplicationSettings_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_ApplicationSettings" ("applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "isBot", "isPublicRepository", "previews", "updatedAt") SELECT "applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "isBot", "isPublicRepository", "previews", "updatedAt" FROM "ApplicationSettings"; +DROP TABLE "ApplicationSettings"; +ALTER TABLE "new_ApplicationSettings" RENAME TO "ApplicationSettings"; +CREATE UNIQUE INDEX "ApplicationSettings_applicationId_key" ON "ApplicationSettings"("applicationId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index 383ea2035..5b2cc4e68 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -128,6 +128,7 @@ model ApplicationSettings { autodeploy Boolean @default(true) isBot Boolean @default(false) isPublicRepository Boolean @default(false) + isDBBranching Boolean @default(false) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt application Application @relation(fields: [applicationId], references: [id])