Repository navigation
Expand file tree
/
Copy pathschema.prisma
More file actions
132 lines (113 loc) · 3.81 KB
/
Copy pathschema.prisma
File metadata and controls
132 lines (113 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Get a free hosted Postgres database in seconds: `npx create-db`
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
}
// Shareable app state models
model SharedLink {
id String @id @default(cuid())
userId String? // Optional - null for anonymous shares
pageName String // 'text', 'json', 'base64'
tabName String // 'diff', 'format', etc.
title String // User-provided title
comment String? // Optional user-provided comment
expiresAt DateTime? // Null = never expires
passwordHash String? // Null = public access
viewCount Int @default(0)
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
content SharedContent?
@@index([pageName])
@@index([createdAt])
@@index([expiresAt])
@@index([userId])
}
model SharedContent {
id String @id @default(cuid())
linkId String @unique
state Json // Page-specific state as JSON
link SharedLink @relation(fields: [linkId], references: [id], onDelete: Cascade)
@@index([linkId])
}
// Saved items model for user bookmarks/saved content
model SavedItem {
id String @id @default(cuid())
userId String? // Optional - null for anonymous saves
pageName String // 'text', 'json', 'base64'
tabName String // 'diff', 'format', etc.
name String // User-provided name
content Json // Page-specific content as JSON
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([pageName])
@@index([createdAt])
@@index([userId])
}
model ShortenedUrl {
id String @id @default(cuid())
shortCode String @unique
originalUrl String
clicks Int @default(0)
userId String?
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([shortCode])
@@index([userId])
@@index([createdAt])
}
// ─── Authentication ──────────────────────────────────────────────────────
model User {
id String @id @default(uuid())
email String @unique
name String
emailVerified Boolean @default(false)
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
shares SharedLink[]
savedItems SavedItem[]
shortenedUrls ShortenedUrl[]
sessions Session[]
accounts Account[]
}
model Session {
id String @id
expiresAt DateTime
token String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ipAddress String?
userAgent String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Account {
id String @id
accountId String
providerId String
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
accessToken String?
refreshToken String?
idToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Verification {
id String @id
identifier String
value String
expiresAt DateTime
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
}