Skip to content

Commit feca76a

Browse files
committed
chore(schema): Improve card model
1 parent f6e043e commit feca76a

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

apps/backend/prisma/schema.prisma

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,39 @@ model PlatformLink {
9595
@@map("platform_links")
9696
}
9797

98+
enum CardVisibility {
99+
PUBLIC // Anyone can view the card
100+
UNLISTED // Anyone with the link can view, but not publicly listed
101+
PRIVATE // Only the card owner can view
102+
}
103+
98104
model Card {
99105
id String @id @default(uuid())
100106
userId String @map("user_id")
107+
101108
title String
109+
description String?
110+
111+
slug String @unique
112+
113+
visibility CardVisibility @default(PUBLIC)
114+
115+
qrEnabled Boolean @default(true)
116+
117+
viewCount Int @default(0)
118+
102119
isDefault Boolean @default(false) @map("is_default")
103120
createdAt DateTime @default(now()) @map("created_at")
104121
updatedAt DateTime @updatedAt @map("updated_at")
105122
106123
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
124+
107125
cardLinks CardLink[]
108126
views CardView[]
109127
110128
@@map("cards")
129+
@@index([slug])
130+
@@index([viewCount])
111131
}
112132

113133
model CardLink {
@@ -145,7 +165,7 @@ model CardView {
145165
cardId String? @map("card_id") // null = default profile view
146166
ownerId String @map("owner_id") // card/profile owner
147167
viewerId String? @map("viewer_id") // null = anonymous web viewer
148-
viewerIp String? @map("viewer_ip")
168+
viewerIp String? @map("viewer_ip") //hashed
149169
viewerAgent String? @map("viewer_agent")
150170
source String @default("qr") // "qr" | "link" | "web" | "app"
151171
createdAt DateTime @default(now()) @map("created_at")

0 commit comments

Comments
 (0)