|
| 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