aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-14 01:14:42 +0000
committerMohamedBassem <me@mbassem.com>2024-02-14 01:14:42 +0000
commit580b842f7835a3d1fa171afdc7e0b52cc3f9dfc6 (patch)
treea33738be581d11a785e82541ffcb304b7757e292
parentdde49dd60e00653960223b8dcea3488b7845d43b (diff)
downloadkarakeep-580b842f7835a3d1fa171afdc7e0b52cc3f9dfc6.tar.zst
fix: Fix the uniquness constraint on tag name
-rw-r--r--packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql11
-rw-r--r--packages/db/prisma/schema.prisma5
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql b/packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql
new file mode 100644
index 00000000..cbcd8821
--- /dev/null
+++ b/packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql
@@ -0,0 +1,11 @@
+/*
+ Warnings:
+
+ - A unique constraint covering the columns `[userId,name]` on the table `BookmarkTags` will be added. If there are existing duplicate values, this will fail.
+
+*/
+-- DropIndex
+DROP INDEX "BookmarkTags_name_key";
+
+-- CreateIndex
+CREATE UNIQUE INDEX "BookmarkTags_userId_name_key" ON "BookmarkTags"("userId", "name");
diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma
index e77297c6..8a681a0b 100644
--- a/packages/db/prisma/schema.prisma
+++ b/packages/db/prisma/schema.prisma
@@ -102,8 +102,7 @@ model BookmarkedLink {
model BookmarkTags {
id String @id @default(cuid())
- // TODO: Tags are unique per user not globally
- name String @unique
+ name String
createdAt DateTime @default(now())
userId String
@@ -111,6 +110,8 @@ model BookmarkTags {
// Relations
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
bookmarks TagsOnBookmarks[]
+
+ @@unique([userId, name])
}
model TagsOnBookmarks {