From 685e2cece425e772ec1895999af56110c00510c7 Mon Sep 17 00:00:00 2001 From: Hebi Li Date: Fri, 18 Aug 2023 11:21:45 -0700 Subject: [PATCH] lab: different options for snapshot schema --- api/prisma/schema.prisma | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 45aecf1e..59baf137 100755 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -67,6 +67,43 @@ model UserRepoData { @@id([userId, repoId]) } +model Snapshot1 { + id String @id + createdAt DateTime @default(now()) + yDocBlob Bytes? + Repo Repo @relation(fields: [repoId], references: [id]) + repoId String +} + +model Blob { + id String @id + updatedAt DateTime @updatedAt + yDocBlob Bytes? + Repo Repo[] +} + +model Snapshot { + id String @id + createdAt DateTime @default(now()) + message String? + yDocBlob Bytes? + Repo Repo? @relation(fields: [repoId], references: [id]) + repoId String? +} + +model UnifiedBlob { + id String @id + updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + + // FIXME history repo should be one repo, not a list. + yDocBlob Bytes? + history Repo[] + + current Repo? @relation("HISTORY", fields: [repoId], references: [id]) + repoId String? +} + model Repo { id String @id name String? @@ -82,7 +119,20 @@ model Repo { updatedAt DateTime @default(now()) @updatedAt UserRepoData UserRepoData[] stargazers User[] @relation("STAR") - yDocBlob Bytes? + + // Option 1: + yDocBlob1 Bytes? + yDocSnapshots1 Snapshot1[] + + // Option 2: + yDocBlob2 Blob? @relation(fields: [yDocBlob2Id], references: [id]) + yDocBlob2Id String? + yDocSnapshots2 Snapshot[] + + // Option 3: + yDocBlob3 UnifiedBlob? @relation(fields: [yDocBlob3Id], references: [id]) + yDocBlob3Id String? + yDocSnapshots3 UnifiedBlob[] @relation("HISTORY") } enum PodType {