From 44b50ba7f6b6f2f417d88efef225d2d96094f6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <git@minelli.me> Date: Tue, 30 Apr 2024 13:14:35 +0200 Subject: [PATCH] DB => Add secret to Assignment --- .../migration.sql | 3 +++ .../migration.sql | 12 ++++++++++++ ExpressAPI/prisma/schema.prisma | 1 + 3 files changed, 16 insertions(+) create mode 100644 ExpressAPI/prisma/migrations/20240430110701_add_assignment_secret/migration.sql create mode 100644 ExpressAPI/prisma/migrations/20240430110915_make_assignment_secret_unique/migration.sql diff --git a/ExpressAPI/prisma/migrations/20240430110701_add_assignment_secret/migration.sql b/ExpressAPI/prisma/migrations/20240430110701_add_assignment_secret/migration.sql new file mode 100644 index 0000000..7e74c26 --- /dev/null +++ b/ExpressAPI/prisma/migrations/20240430110701_add_assignment_secret/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE `Assignment` ADD COLUMN `secret` CHAR(36) NULL; +UPDATE `Assignment` SET `secret` = uuid(); \ No newline at end of file diff --git a/ExpressAPI/prisma/migrations/20240430110915_make_assignment_secret_unique/migration.sql b/ExpressAPI/prisma/migrations/20240430110915_make_assignment_secret_unique/migration.sql new file mode 100644 index 0000000..ee45877 --- /dev/null +++ b/ExpressAPI/prisma/migrations/20240430110915_make_assignment_secret_unique/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - A unique constraint covering the columns `[secret]` on the table `Assignment` will be added. If there are existing duplicate values, this will fail. + - Made the column `secret` on table `Assignment` required. This step will fail if there are existing NULL values in that column. + +*/ +-- AlterTable +ALTER TABLE `Assignment` MODIFY `secret` CHAR(36) NOT NULL; + +-- CreateIndex +CREATE UNIQUE INDEX `Assignment_secret_key` ON `Assignment`(`secret`); diff --git a/ExpressAPI/prisma/schema.prisma b/ExpressAPI/prisma/schema.prisma index 2d894bb..ee2c0f1 100644 --- a/ExpressAPI/prisma/schema.prisma +++ b/ExpressAPI/prisma/schema.prisma @@ -35,6 +35,7 @@ model User { model Assignment { name String @id + secret String @unique @db.Char(36) gitlabId Int gitlabLink String gitlabCreationInfo Json @db.Json -- GitLab