hermes-web/prisma/schema.prisma

223 lines
5.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
// datasource db {
// provider = "mysql"
// url = env("DATABASE_URL")
// relationMode = "prisma"
// }
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum UserRole {
USER
ADMIN
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
role UserRole @default(USER)
image String?
ttsDefaultVoice String @default("Brian")
impersonationSources Impersonation[] @relation(name: "impersonationSources")
impersonationTargets Impersonation[] @relation(name: "impersonationTargets")
apiKeys ApiKey[]
accounts Account[]
twitchConnections TwitchConnection[]
ttsUsernameFilter TtsUsernameFilter[]
ttsWordFilter TtsWordFilter[]
ttsChatVoices TtsChatVoice[]
ttsVoiceStates TtsVoiceState[]
actions Action[]
redemptions Redemption[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@unique([provider, providerAccountId])
}
model Impersonation {
sourceId String
targetId String
source User @relation(name: "impersonationSources", fields: [sourceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
target User @relation(name: "impersonationTargets", fields: [targetId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@id([sourceId])
@@index([sourceId])
@@index([targetId])
}
model ApiKey {
id String @id @default(uuid())
label String
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
}
model TwitchConnection {
broadcasterId String @unique
accessToken String
refreshToken String
userId String @id
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
}
model TtsUsernameFilter {
username String
tag String
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@id([userId, username])
}
model TtsWordFilter {
id String @id @default(cuid())
search String
replace String
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@unique([userId, search])
}
model TtsVoice {
id String @id @default(cuid())
name String
ttsChatVoices TtsChatVoice[]
ttsVoiceStates TtsVoiceState[]
}
model TtsChatVoice {
userId String
chatterId BigInt
ttsVoiceId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
voice TtsVoice @relation(fields: [ttsVoiceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@id([userId, chatterId])
@@index([userId])
}
model TtsVoiceState {
userId String
ttsVoiceId String
state Boolean @default(true)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
voice TtsVoice @relation(fields: [ttsVoiceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@id([userId, ttsVoiceId])
}
model Chatter {
id BigInt
name String
ban DateTime @default(dbgenerated("'1970-01-01 00:00:00.000'"))
//history EmoteUsageHistory[]
@@id([id])
}
model Emote {
id String
name String
//history EmoteUsageHistory[]
@@id([id])
}
model EmoteUsageHistory {
timestamp DateTime
broadcasterId BigInt
emoteId String
chatterId BigInt
//emote Emote @relation(fields: [emoteId], references: [id], onDelete: Cascade, onUpdate: Cascade)
//chatter Chatter @relation(fields: [chatterId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@id([timestamp, emoteId, chatterId])
}
enum ActionType {
WRITE_TO_FILE
APPEND_TO_FILE
AUDIO_FILE
OBS_TRANSFORM
}
model Action {
userId String
name String @unique
type ActionType
data Json
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, name])
}
model Redemption {
id String @id @default(uuid()) @db.Uuid
userId String
redemptionId String
actionName String
order Int
state Boolean
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Quest {
id Int @id @default(autoincrement())
type Int
target Int
start DateTime
end DateTime
@@unique([type, start])
}
model QuestProgression {
chatterId BigInt
questId Int
counter Int
@@id([chatterId, questId])
}