2022-05-17 23:48:59 +00:00
|
|
|
generator client {
|
2022-05-21 19:33:23 +00:00
|
|
|
provider = "prisma-client-js"
|
2022-05-17 23:48:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-14 10:22:06 +00:00
|
|
|
datasource db {
|
2022-05-21 19:33:23 +00:00
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
model TwilioAccount {
|
2023-04-29 16:30:07 +00:00
|
|
|
accountSid String @id
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
|
|
|
updatedAt DateTime @updatedAt @db.Timestamptz(6)
|
|
|
|
authToken String
|
|
|
|
twimlAppSid String?
|
|
|
|
apiKeySid String?
|
|
|
|
apiKeySecret String?
|
|
|
|
phoneNumbers PhoneNumber[]
|
|
|
|
notificationSubscriptions NotificationSubscription[]
|
|
|
|
sessions Session[]
|
2022-05-14 10:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model Session {
|
2023-04-29 16:30:07 +00:00
|
|
|
id String @id @default(cuid())
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
|
|
|
updatedAt DateTime @updatedAt @db.Timestamptz(6)
|
|
|
|
expiresAt DateTime? @db.Timestamptz(6)
|
|
|
|
data String
|
|
|
|
twilioAccountSid String?
|
|
|
|
twilioAccount TwilioAccount? @relation(fields: [twilioAccountSid], references: [accountSid], onDelete: Cascade)
|
2022-05-14 10:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model Message {
|
2022-05-21 19:33:23 +00:00
|
|
|
id String @id
|
|
|
|
sentAt DateTime @db.Timestamptz(6)
|
|
|
|
content String
|
2022-05-21 23:17:43 +00:00
|
|
|
recipient String
|
2022-05-21 19:33:23 +00:00
|
|
|
from String
|
|
|
|
to String
|
|
|
|
direction Direction
|
|
|
|
status MessageStatus
|
|
|
|
phoneNumberId String
|
|
|
|
phoneNumber PhoneNumber @relation(fields: [phoneNumberId], references: [id], onDelete: Cascade)
|
2022-05-21 23:17:43 +00:00
|
|
|
|
|
|
|
@@index([phoneNumberId, recipient])
|
2022-05-17 23:48:59 +00:00
|
|
|
}
|
2022-05-14 10:22:06 +00:00
|
|
|
|
2022-05-17 23:48:59 +00:00
|
|
|
model PhoneCall {
|
2022-05-21 19:33:23 +00:00
|
|
|
id String @id
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
2022-05-21 23:17:43 +00:00
|
|
|
recipient String
|
2022-05-21 19:33:23 +00:00
|
|
|
from String
|
|
|
|
to String
|
|
|
|
status CallStatus
|
|
|
|
direction Direction
|
|
|
|
duration String
|
|
|
|
phoneNumberId String
|
|
|
|
phoneNumber PhoneNumber @relation(fields: [phoneNumberId], references: [id], onDelete: Cascade)
|
2022-05-21 23:17:43 +00:00
|
|
|
|
|
|
|
@@index([phoneNumberId, recipient])
|
2022-05-17 23:48:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model PhoneNumber {
|
2022-06-11 00:09:37 +00:00
|
|
|
id String @id
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamptz(6)
|
2022-05-21 19:33:23 +00:00
|
|
|
number String
|
|
|
|
isCurrent Boolean
|
|
|
|
isFetchingMessages Boolean?
|
|
|
|
isFetchingCalls Boolean?
|
2022-06-11 00:09:37 +00:00
|
|
|
twilioAccountSid String
|
|
|
|
twilioAccount TwilioAccount @relation(fields: [twilioAccountSid], references: [accountSid], onDelete: Cascade)
|
2022-05-21 19:33:23 +00:00
|
|
|
messages Message[]
|
|
|
|
phoneCalls PhoneCall[]
|
2022-05-17 23:48:59 +00:00
|
|
|
|
2022-06-11 00:09:37 +00:00
|
|
|
@@unique([twilioAccountSid, isCurrent])
|
2022-05-17 23:48:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-30 00:21:42 +00:00
|
|
|
model NotificationSubscription {
|
|
|
|
id String @id @default(uuid())
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamptz
|
|
|
|
updatedAt DateTime @updatedAt @db.Timestamptz
|
|
|
|
endpoint String @unique
|
|
|
|
expirationTime Int?
|
|
|
|
keys_p256dh String
|
|
|
|
keys_auth String
|
|
|
|
|
2023-04-29 16:30:07 +00:00
|
|
|
twilioAccount TwilioAccount @relation(fields: [twilioAccountSid], references: [accountSid], onDelete: Cascade)
|
|
|
|
twilioAccountSid String
|
2022-05-14 10:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Direction {
|
2022-05-21 19:33:23 +00:00
|
|
|
Inbound
|
|
|
|
Outbound
|
2022-05-14 10:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum MessageStatus {
|
2022-05-21 19:33:23 +00:00
|
|
|
Queued
|
|
|
|
Sending
|
|
|
|
Sent
|
|
|
|
Failed
|
|
|
|
Delivered
|
|
|
|
Undelivered
|
|
|
|
Receiving
|
|
|
|
Received
|
|
|
|
Accepted
|
|
|
|
Scheduled
|
|
|
|
Read
|
|
|
|
PartiallyDelivered
|
|
|
|
Canceled
|
|
|
|
Error
|
2022-05-14 10:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum CallStatus {
|
2022-05-21 19:33:23 +00:00
|
|
|
Queued
|
|
|
|
Ringing
|
|
|
|
InProgress
|
|
|
|
Completed
|
|
|
|
Busy
|
|
|
|
Failed
|
|
|
|
NoAnswer
|
|
|
|
Canceled
|
2022-05-14 10:22:06 +00:00
|
|
|
}
|