Skip to content

Commit 9654a07

Browse files
committed
feat: init prisma schema
1 parent 9d1d900 commit 9654a07

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ node_modules
33
/.cache
44
/build
55
.env
6-
.eslintcache
6+
.eslintcache
7+
/prisma/docs
8+
prisma/credentials

bun.lockb

2.43 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"clsx": "^2.1.1",
2424
"isbot": "^4.1.0",
2525
"lucide-react": "^0.403.0",
26+
"prisma": "^5.17.0",
2627
"react": "^18.2.0",
2728
"react-dom": "^18.2.0",
2829
"simple-icons": "^13.1.0",

prisma/schema.prisma

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// This is your Prisma schema file,
2+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
3+
4+
generator client {
5+
provider = "prisma-client-js"
6+
previewFeatures = ["driverAdapters"]
7+
}
8+
9+
datasource db {
10+
provider = "postgresql"
11+
url = env("DATABASE_URL")
12+
}
13+
14+
model User {
15+
id String @id @default(cuid())
16+
17+
email String @unique
18+
username String @unique
19+
phone String? @unique // numeric string
20+
21+
fullname String
22+
nickname String?
23+
24+
profile UserProfile?
25+
userProfileId String @unique
26+
role Role @relation(fields: [roleId], references: [id])
27+
roleId String
28+
29+
createdAt DateTime @default(now())
30+
updatedAt DateTime @updatedAt
31+
32+
@@index([id])
33+
@@index([email])
34+
}
35+
36+
model Role {
37+
id String @id @default(cuid())
38+
39+
sequence Int? @unique // 1, 2, 3, ...
40+
symbol String @unique // ROOT, ADMIN, MEMBER, ...
41+
name String @unique // Root, Admin, Member, ...
42+
description String? @db.Text // Summary of abilities
43+
44+
users User[]
45+
46+
createdAt DateTime @default(now())
47+
updatedAt DateTime @updatedAt
48+
49+
@@index([symbol])
50+
}
51+
52+
model Event {
53+
id String @id @default(cuid())
54+
55+
slug String @unique
56+
title String @db.Text
57+
description String @db.Text
58+
content String? @db.Text // Rich HTML Text
59+
url String? // Url for online or hybrid
60+
61+
dateTimeStart DateTime @default(now())
62+
dateTimeEnd DateTime @default(now())
63+
64+
imageUrl String
65+
66+
locationName String
67+
locationAddress String?
68+
69+
eventAgendas EventAgenda[]
70+
71+
registration String @db.Text
72+
73+
createdAt DateTime @default(now())
74+
updatedAt DateTime @updatedAt
75+
}
76+
77+
model EventAgenda {
78+
id String @id @default(cuid())
79+
title String
80+
description String
81+
speaker UserProfile? @relation(fields: [userProfileId], references: [id])
82+
userProfileId String?
83+
Event Event? @relation(fields: [eventId], references: [id])
84+
eventId String?
85+
dateTimeStart DateTime
86+
dateTimeEnd DateTime
87+
}
88+
89+
// used by User & Event (event agenda has speakers)
90+
model UserProfile {
91+
id String @id @default(cuid())
92+
93+
user User @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade)
94+
userId String @unique
95+
96+
headline String?
97+
avatar String?
98+
99+
createdAt DateTime @default(now())
100+
updatedAt DateTime @updatedAt
101+
eventAgendas EventAgenda[]
102+
103+
@@unique([id, userId])
104+
@@index([userId])
105+
}

0 commit comments

Comments
 (0)