From a4d4bf611ce40d891b625557d9c779c6f10812d1 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 7 Dec 2024 15:24:17 +0100 Subject: [PATCH] Set hashedKey to unique --- .../migration.sql | 5 +++++ prisma/schema.prisma | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 prisma/migrations/20241207142023_set_hashed_key_of_api_key_to_unique/migration.sql diff --git a/prisma/migrations/20241207142023_set_hashed_key_of_api_key_to_unique/migration.sql b/prisma/migrations/20241207142023_set_hashed_key_of_api_key_to_unique/migration.sql new file mode 100644 index 000000000..f9a6eecbb --- /dev/null +++ b/prisma/migrations/20241207142023_set_hashed_key_of_api_key_to_unique/migration.sql @@ -0,0 +1,5 @@ +-- DropIndex +DROP INDEX "ApiKey_hashedKey_idx"; + +-- CreateIndex +CREATE UNIQUE INDEX "ApiKey_hashedKey_key" ON "ApiKey"("hashedKey"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e2587acf7..7df28d694 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -79,13 +79,12 @@ model Analytics { model ApiKey { createdAt DateTime @default(now()) - hashedKey String + hashedKey String @unique id String @id @default(uuid()) updatedAt DateTime @updatedAt userId String user User @relation(fields: [userId], onDelete: Cascade, references: [id]) - @@index([hashedKey]) @@index([userId]) }