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[] Connection Connection[] ConnectionState ConnectionState[] ttsUsernameFilter TtsUsernameFilter[] ttsWordFilter TtsWordFilter[] ttsChatVoices TtsChatVoice[] ttsVoiceStates TtsVoiceState[] actions Action[] redemptions Redemption[] groups Group[] chatterGroups ChatterGroup[] groupPermissions GroupPermission[] 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 Connection { name String type String clientId String accessToken String grantType String scope String expiresAt DateTime default Boolean @default(false) userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) @@id([userId, name]) } model ConnectionState { state String name String type String grantType String clientId String userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) @@id([userId, name]) @@unique([state]) } 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 Group { id String @id @default(uuid()) @db.Uuid userId String name String priority Int chatters ChatterGroup[] permissions GroupPermission[] user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([userId, name]) @@index([userId]) } model ChatterGroup { //id String @id @default(uuid()) @db.Uuid userId String groupId String @db.Uuid chatterId BigInt chatterLabel String user User @relation(fields: [userId], references: [id], onDelete: Cascade) group Group @relation(fields: [groupId], references: [id], onDelete: Cascade) @@id([userId, groupId, chatterId]) @@unique([userId, groupId, chatterId]) @@index([userId]) } model GroupPermission { id String @id @default(uuid()) @db.Uuid userId String groupId String @db.Uuid path String allow Boolean? user User @relation(fields: [userId], references: [id], onDelete: Cascade) group Group @relation(fields: [groupId], references: [id], onDelete: Cascade) @@unique([userId, groupId, path]) @@index([userId]) } 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]) @@unique([id, name]) } 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 RANDOM_TTS_VOICE SPECIFIC_TTS_VOICE TOGGLE_OBS_VISIBILITY SPECIFIC_OBS_VISIBILITY SPECIFIC_OBS_INDEX SLEEP OAUTH NIGHTBOT_PLAY NIGHTBOT_PAUSE NIGHTBOT_SKIP NIGHTBOT_CLEAR_PLAYLIST NIGHTBOT_CLEAR_QUEUE TWITCH_OAUTH } 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]) }