- Change LinkedAccount unique constraint to (userId, serviceId, accountId) - Add linkedAccountId to StreamDestination for per-account targeting - OAuth callbacks upsert by accountId so different accounts create new rows - Delete endpoint changed to /providers/accounts/:id - getDecryptedToken resolves tokens by linkedAccountId instead of serviceId - /start transition wrapped in try-catch (enableAutoStart compatibility) - /end always attempts YouTube complete transition regardless of plan status - autoDetectEndedPlans loads tokens per-destination
87 lines
2.4 KiB
Plaintext
87 lines
2.4 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
metaId String @unique
|
|
displayName String
|
|
email String?
|
|
avatarUrl String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
linkedAccounts LinkedAccount[]
|
|
streamPlans StreamPlan[]
|
|
sessions Session[]
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
refreshToken String @unique
|
|
expiresAt DateTime
|
|
deviceInfo String?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model LinkedAccount {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
serviceId String
|
|
displayName String
|
|
accountId String
|
|
avatarUrl String?
|
|
accessTokenEnc String
|
|
refreshTokenEnc String
|
|
tokenExpiresAt DateTime
|
|
accessTokenIv String
|
|
refreshTokenIv String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([userId, serviceId, accountId])
|
|
@@index([userId])
|
|
}
|
|
|
|
model StreamPlan {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
name String
|
|
status String @default("DRAFT")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
destinations StreamDestination[]
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model StreamDestination {
|
|
id String @id @default(uuid())
|
|
planId String
|
|
plan StreamPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
|
serviceId String
|
|
linkedAccountId String @default("")
|
|
title String
|
|
description String @default("")
|
|
privacyStatus String @default("public")
|
|
gameId String @default("")
|
|
tags String @default("")
|
|
rtmpUrl String @default("")
|
|
streamKey String @default("")
|
|
broadcastId String @default("")
|
|
status String @default("PENDING")
|
|
|
|
@@index([planId])
|
|
}
|