Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions apps/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ model User {
organizer Event[]
attendedEvents EventAttendee[]

webhookEndpoints WebhookEndpoint[]
ownedTeams Team[] @relation("TeamOwner")
teamMemberships TeamMember[] @relation("TeamMember")

Expand Down Expand Up @@ -142,22 +143,56 @@ model Event {
isPublic Boolean @default(true)
createdAt DateTime @default(now()) @map("created_at")
attendees EventAttendee[]

organizer User @relation(fields: [organizerId], references: [id])
}

model EventAttendee {
id String @id @default(uuid())
userId String
eventId String
joinedAt DateTime
joinedAt DateTime

event Event @relation(fields: [eventId] , references: [id])
user User @relation(fields: [userId],references: [id])

@@unique([userId, eventId])
}

model WebhookEndpoint {
id String @id @default(uuid())
userId String @map("user_id")
url String
secret String
events String[]
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@index([userId])
@@map("webhook_endpoints")
}

model WebhookDelivery {
id String @id @default(uuid())
endpointId String @map("endpoint_id")
eventType String @map("event_type")
payload Json
status String @default("pending") // "pending" | "success" | "failed"
responseCode Int? @map("response_code")
attempts Int @default(0)
nextRetryAt DateTime? @map("next_retry_at")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
errorMessage String? @map("error_message")
deliveredAt DateTime? @map("delivered_at")

@@index([endpointId])
@@index([status, nextRetryAt])
@@map("webhook_deliveries")
}

enum TeamRole {
OWNER
ADMIN
Expand Down Expand Up @@ -194,4 +229,4 @@ model TeamMember{
@@unique([userId, teamId])
@@index([userId])
@@map("team_members")
}
}
Loading
Loading