diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-06 00:09:16 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-06 00:09:16 +0000 |
| commit | 81531a46c368293b736bb3b12c413cfbe6e00ec4 (patch) | |
| tree | ab7508cc5b8f36df9bdca80f40ff1ce822a9ac53 /prisma/schema.prisma | |
| parent | e47bfb069c1035f5320a06b1f6d26b90692fbf93 (diff) | |
| download | karakeep-81531a46c368293b736bb3b12c413cfbe6e00ec4.tar.zst | |
[models] Model bookmarked links in prisma
Diffstat (limited to 'prisma/schema.prisma')
| -rw-r--r-- | prisma/schema.prisma | 77 |
1 files changed, 63 insertions, 14 deletions
diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0789cab8..54be3eae 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -11,18 +11,18 @@ datasource db { } model Account { - id String @id @default(cuid()) - userId String - type String - provider String - providerAccountId String - refresh_token String? - access_token String? - expires_at Int? - token_type String? - scope String? - id_token String? - session_state String? + id String @id @default(cuid()) + userId String + type String + provider String + providerAccountId String + refresh_token String? + access_token String? + expires_at Int? + token_type String? + scope String? + id_token String? + session_state String? user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@ -38,13 +38,15 @@ model Session { } model User { - id String @id @default(cuid()) + id String @id @default(cuid()) name String? - email String? @unique + email String? @unique emailVerified DateTime? image String? accounts Account[] sessions Session[] + links BookmarkedLink[] + tags BookmarkTags[] } model VerificationToken { @@ -54,3 +56,50 @@ model VerificationToken { @@unique([identifier, token]) } + +model BookmarkedLink { + id String @id @default(cuid()) + url String + createdAt DateTime @default(now()) + + userId String + + details BookmarkedLinkDetails? + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + tags TagsOnLinks[] +} + +model BookmarkedLinkDetails { + id String @id + title String + description String + imageUrl String + createdAt DateTime @default(now()) + + link BookmarkedLink @relation(fields: [id], references: [id], onDelete: Cascade) +} + +model BookmarkTags { + id String @id @default(cuid()) + name String @unique + createdAt DateTime @default(now()) + + userId String + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + attachedLinks TagsOnLinks[] +} + +model TagsOnLinks { + link BookmarkedLink @relation(fields: [linkId], references: [id], onDelete: Cascade) + linkId String + + tag BookmarkTags @relation(fields: [tagId], references: [id], onDelete: Cascade) + tagId String + + attachedAt DateTime @default(now()) + bookmarkTagsId String + + @@unique([linkId, tagId]) +} |
