Skip to content

Commit fc28fb8

Browse files
committed
feat: apply card sharing backend changes with auth fix
1 parent 52e4df1 commit fc28fb8

11 files changed

Lines changed: 1019 additions & 484 deletions

File tree

apps/backend/prisma/migrations/20260312125106_init/migration.sql

Lines changed: 0 additions & 99 deletions
This file was deleted.

apps/backend/prisma/migrations/20260312162249_analytics_models/migration.sql

Lines changed: 0 additions & 38 deletions
This file was deleted.

apps/backend/prisma/schema.prisma

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,40 @@ 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[]
127+
109128
110129
@@map("cards")
130+
@@index([userId])
131+
@@index([viewCount])
111132
}
112133

113134
model CardLink {
@@ -145,7 +166,7 @@ model CardView {
145166
cardId String? @map("card_id") // null = default profile view
146167
ownerId String @map("owner_id") // card/profile owner
147168
viewerId String? @map("viewer_id") // null = anonymous web viewer
148-
viewerIp String? @map("viewer_ip")
169+
viewerIp String? @map("viewer_ip") //hashed
149170
viewerAgent String? @map("viewer_agent")
150171
source String @default("qr") // "qr" | "link" | "web" | "app"
151172
createdAt DateTime @default(now()) @map("created_at")
@@ -155,6 +176,8 @@ model CardView {
155176
viewer User? @relation("cardViewer", fields: [viewerId], references: [id], onDelete: SetNull)
156177
157178
@@map("card_views")
179+
@@index([cardId])
180+
@@index([ownerId])
158181
}
159182

160183
model FollowLog {

0 commit comments

Comments
 (0)