Files

67 lines
1.8 KiB
Plaintext

generator client {
provider = "prisma-client-js"
// include for node docker image
binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("POSTGRES_URL")
}
model Attachment {
id BigInt @id
msgId BigInt
channelId BigInt
memeId String @unique @db.Uuid
meme Meme @relation(fields: [memeId], references: [id], onDelete: Restrict)
url String
contentType String
message Json
guild Json
channel Json
vision Json
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
postedAt DateTime
@@index([channelId])
@@map("attachments")
}
model Meme {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
url String
text String
tags Json
// need an timestamp for giving to meili to sort by
// i think a usize would actually work but can't
// convince the meili-js lib to serialize it properly to json
// this one actually has to be .valueOf()'d before we send it
// cause js numbers are bigger than postgres int4
postedAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
// required to prevent the same attachment being uploaded multiple times
// nullable because maybe will have memes that don't come from a discord attachment
attachmentId BigInt? @unique
attachment Attachment?
@@map("memes")
}
model ChannelHistory {
id BigInt @id
earliestMessageId BigInt
latestMessageId BigInt
// we do this because you have to always wrap table names in "" if they have capitals
@@map("channelhistory")
}