mirror of
https://github.com/jetkvm/cloud-api.git
synced 2026-05-21 05:20:36 +00:00
b24a057591
* feat: add SKU-aware OTA release artifacts Persist OTA artifact URL/hash data separately from rollout state so stable release responses can choose artifacts by compatible SKU while release rollout remains version/type based. * fix: select compatible OTA releases by SKU Ensure stable release selection only considers releases with artifacts compatible with the requested SKU, and tighten tests around the DB-backed OTA contract. * fix: match production OTA release responses Only expose stable signature URLs that actually exist and preserve production's version-first SKU error behavior. * fix: restrict legacy OTA artifacts and make sync create-only Pre-SKU artifacts (no skus/ folder) are jetkvm-v2 only. Marking them compatible with jetkvm-v2-sdmmc would brick devices that received firmware predating their hardware. Future SKUs must opt in via an explicit skus/<sku>/ upload. sync-releases now skips releases already in the DB instead of upserting them. This prevents routine sync runs from rewriting Release.url/hash or appending duplicate ReleaseArtifact rows if R2_CDN_URL ever changes. Backfills and repairs are left to one-off scripts. * refactor: drop forceUpdate query parameter from /releases The flag is no longer sent by any client. Routine update checks now always go through the rollout-aware default-and-latest path, which is what forceUpdate effectively short-circuited to. Removes one query parameter, one branch in the handler, and the corresponding axis from the compare-releases sweep. * fix: skip incompatible defaults and parallelize stable DB lookups getDefaultRelease previously picked the newest 100%-rolled-out release without checking SKU compatibility. If that release lacked a compatible artifact, the request 404'd downstream even though older 100%-rolled-out releases had valid binaries for the SKU. It now filters to releases that actually ship a compatible artifact before selecting the latest, falling back to a 404 only when no compatible default exists. The four DB lookups in the stable rollout-aware path are independent; run them concurrently so background-check latency drops from ~4 round trips to ~1.
69 lines
1.9 KiB
Plaintext
69 lines
1.9 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id BigInt @id @default(autoincrement())
|
|
googleId String @unique
|
|
email String?
|
|
picture String?
|
|
device Device[]
|
|
Activity TurnActivity[]
|
|
}
|
|
|
|
model Device {
|
|
id String @unique
|
|
lastSeen DateTime? @db.Timestamp(6)
|
|
name String?
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId BigInt
|
|
tempToken String?
|
|
tempTokenExpiresAt DateTime?
|
|
secretToken String? @unique
|
|
}
|
|
|
|
model TurnActivity {
|
|
id BigInt @id @default(autoincrement())
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId BigInt
|
|
createdAt DateTime? @default(now()) @db.Timestamp(6)
|
|
bytesSent Int
|
|
bytesReceived Int
|
|
}
|
|
|
|
model Release {
|
|
id BigInt @id @default(autoincrement())
|
|
version String
|
|
rolloutPercentage Int @default(10) // 10% of users
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
url String
|
|
type String @default("app") // "app" or "system"
|
|
hash String
|
|
artifacts ReleaseArtifact[]
|
|
|
|
@@unique([version, type])
|
|
}
|
|
|
|
model ReleaseArtifact {
|
|
id BigInt @id @default(autoincrement())
|
|
release Release @relation(fields: [releaseId], references: [id], onDelete: Cascade)
|
|
releaseId BigInt
|
|
url String
|
|
hash String
|
|
compatibleSkus String[]
|
|
|
|
@@unique([releaseId, url])
|
|
}
|