- Prisma: Device model (Quest/Phone, online status, battery, storage, game/streaming/cortex state), Video model with likes, VideoLike - Signaling WebSocket for SDP/ICE relay and device presence - Device routes: list, status, delete - Content routes: video CRUD with range-support streaming - SignalingManager service for device socket registry and heartbeat
187 lines
5.4 KiB
Plaintext
187 lines
5.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?
|
|
bio String @default("")
|
|
isPublic Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
linkedAccounts LinkedAccount[]
|
|
streamPlans StreamPlan[]
|
|
sessions Session[]
|
|
pairingCodes PairingCode[]
|
|
followers Follow[] @relation("following")
|
|
following Follow[] @relation("follower")
|
|
likes Like[]
|
|
devices Device[]
|
|
videos Video[]
|
|
videoLikes VideoLike[]
|
|
}
|
|
|
|
model PairingCode {
|
|
id String @id @default(uuid())
|
|
code String @unique
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
expiresAt DateTime
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
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")
|
|
executionMode String @default("IN_GAME")
|
|
gameId String @default("")
|
|
isPublic Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
destinations StreamDestination[]
|
|
likes Like[]
|
|
|
|
@@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])
|
|
}
|
|
|
|
model Follow {
|
|
id String @id @default(uuid())
|
|
followerId String
|
|
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)
|
|
followingId String
|
|
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([followerId, followingId])
|
|
@@index([followerId])
|
|
@@index([followingId])
|
|
}
|
|
|
|
model Like {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
planId String
|
|
plan StreamPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([userId, planId])
|
|
@@index([planId])
|
|
}
|
|
|
|
model Device {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
deviceId String
|
|
deviceName String @default("")
|
|
deviceType String @default("QUEST") // "QUEST" or "PHONE"
|
|
isOnline Boolean @default(false)
|
|
lastSeen DateTime @default(now())
|
|
batteryLevel Int?
|
|
storageAvailable Int?
|
|
runningGame String?
|
|
streamingState String?
|
|
cortexState String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([userId, deviceId])
|
|
@@index([userId])
|
|
}
|
|
|
|
model Video {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
title String
|
|
description String @default("")
|
|
duration Int @default(0)
|
|
thumbnailUrl String?
|
|
videoUrl String
|
|
fileSize Int?
|
|
isPublic Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
likes VideoLike[]
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model VideoLike {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
videoId String
|
|
video Video @relation(fields: [videoId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([userId, videoId])
|
|
@@index([videoId])
|
|
}
|