cal/prisma/schema.prisma

230 lines
6.2 KiB
Plaintext
Raw Normal View History

2021-03-22 10:48:48 -03:00
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model EventType {
id Int @id @default(autoincrement())
title String
slug String
description String?
locations Json?
length Int
hidden Boolean @default(false)
user User? @relation(fields: [userId], references: [id])
userId Int?
bookings Booking[]
availability Availability[]
eventName String?
customInputs EventTypeCustomInput[]
timeZone String?
periodType String? @default("unlimited") // unlimited | rolling | range
periodStartDate DateTime?
periodEndDate DateTime?
periodDays Int?
periodCountCalendarDays Boolean?
requiresConfirmation Boolean @default(false)
minimumBookingNotice Int @default(120)
Schedule Schedule[]
@@unique([userId, slug])
2021-03-22 10:48:48 -03:00
}
model Credential {
id Int @id @default(autoincrement())
type String
key Json
user User? @relation(fields: [userId], references: [id])
userId Int?
2021-03-22 10:48:48 -03:00
}
enum UserPlan {
FREE
TRIAL
PRO
}
2021-03-22 10:48:48 -03:00
model User {
id Int @id @default(autoincrement())
username String? @unique
name String?
email String? @unique
emailVerified DateTime?
password String?
bio String?
avatar String?
timeZone String @default("Europe/London")
weekStart String? @default("Sunday")
startTime Int @default(0)
endTime Int @default(1440)
bufferTime Int @default(0)
hideBranding Boolean @default(false)
theme String?
createdDate DateTime @default(now()) @map(name: "created")
eventTypes EventType[]
credentials Credential[]
teams Membership[]
bookings Booking[]
availability Availability[]
selectedCalendars SelectedCalendar[]
completedOnboarding Boolean? @default(false)
plan UserPlan @default(PRO)
Schedule Schedule[]
2021-03-22 10:48:48 -03:00
@@map(name: "users")
}
model Team {
id Int @default(autoincrement()) @id
name String?
slug String? @unique
logo String?
bio String?
hideBranding Boolean @default(false)
members Membership[]
}
enum MembershipRole {
MEMBER
OWNER
}
model Membership {
teamId Int
userId Int
accepted Boolean @default(false)
role MembershipRole
team Team @relation(fields: [teamId], references: [id])
user User @relation(fields: [userId], references: [id])
@@id([userId, teamId])
}
model VerificationRequest {
id Int @id @default(autoincrement())
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([identifier, token])
}
model BookingReference {
id Int @id @default(autoincrement())
type String
uid String
booking Booking? @relation(fields: [bookingId], references: [id])
bookingId Int?
}
model Attendee {
id Int @id @default(autoincrement())
email String
name String
timeZone String
booking Booking? @relation(fields: [bookingId], references: [id])
bookingId Int?
}
model Booking {
id Int @id @default(autoincrement())
uid String @unique
user User? @relation(fields: [userId], references: [id])
userId Int?
references BookingReference[]
eventType EventType? @relation(fields: [eventTypeId], references: [id])
eventTypeId Int?
title String
description String?
startTime DateTime
endTime DateTime
attendees Attendee[]
location String?
createdAt DateTime @default(now())
updatedAt DateTime?
confirmed Boolean @default(true)
rejected Boolean @default(false)
}
model Schedule {
id Int @id @default(autoincrement())
user User? @relation(fields: [userId], references: [id])
userId Int?
eventType EventType? @relation(fields: [eventTypeId], references: [id])
eventTypeId Int?
title String?
freeBusyTimes Json?
2021-06-14 15:53:20 -03:00
}
model Availability {
id Int @id @default(autoincrement())
label String?
user User? @relation(fields: [userId], references: [id])
userId Int?
eventType EventType? @relation(fields: [eventTypeId], references: [id])
eventTypeId Int?
days Int[]
startTime Int
endTime Int
date DateTime? @db.Date
2021-06-14 15:53:20 -03:00
}
2021-06-20 14:52:18 -03:00
model SelectedCalendar {
user User @relation(fields: [userId], references: [id])
userId Int
integration String
externalId String
@@id([userId, integration, externalId])
}
2021-06-19 15:55:40 -03:00
enum EventTypeCustomInputType {
TEXT @map("text")
TEXTLONG @map("textLong")
NUMBER @map("number")
BOOL @map("bool")
}
2021-06-19 15:55:40 -03:00
model EventTypeCustomInput {
id Int @id @default(autoincrement())
2021-06-19 15:55:40 -03:00
eventTypeId Int
eventType EventType @relation(fields: [eventTypeId], references: [id])
2021-06-19 15:55:40 -03:00
label String
type EventTypeCustomInputType
2021-06-19 15:55:40 -03:00
required Boolean
placeholder String @default("")
2021-06-19 15:55:40 -03:00
}
model ResetPasswordRequest {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String
expires DateTime
}
enum ReminderType {
PENDING_BOOKING_CONFIRMATION
}
model ReminderMail {
id Int @id @default(autoincrement())
referenceId Int
reminderType ReminderType
elapsedMinutes Int
createdAt DateTime @default(now())
}