shellphone.app/prisma/schema.prisma

123 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

2022-05-17 23:48:59 +00:00
generator client {
provider = "prisma-client-js"
2022-05-17 23:48:59 +00:00
}
2022-05-14 10:22:06 +00:00
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model TwilioAccount {
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 {
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 {
id String @id
sentAt DateTime @db.Timestamptz(6)
content String
recipient String
from String
to String
direction Direction
status MessageStatus
phoneNumberId String
phoneNumber PhoneNumber @relation(fields: [phoneNumberId], references: [id], onDelete: Cascade)
@@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 {
id String @id
createdAt DateTime @default(now()) @db.Timestamptz(6)
recipient String
from String
to String
status CallStatus
direction Direction
duration String
phoneNumberId String
phoneNumber PhoneNumber @relation(fields: [phoneNumberId], references: [id], onDelete: Cascade)
@@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)
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)
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
}
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
twilioAccount TwilioAccount @relation(fields: [twilioAccountSid], references: [accountSid], onDelete: Cascade)
twilioAccountSid String
2022-05-14 10:22:06 +00:00
}
enum Direction {
Inbound
Outbound
2022-05-14 10:22:06 +00:00
}
enum MessageStatus {
Queued
Sending
Sent
Failed
Delivered
Undelivered
Receiving
Received
Accepted
Scheduled
Read
PartiallyDelivered
Canceled
Error
2022-05-14 10:22:06 +00:00
}
enum CallStatus {
Queued
Ringing
InProgress
Completed
Busy
Failed
NoAnswer
Canceled
2022-05-14 10:22:06 +00:00
}