From 4abe9ce59994b098dafefcea416c9d356e568533 Mon Sep 17 00:00:00 2001 From: repi Date: Mon, 1 Jan 2001 00:00:00 +0000 Subject: [PATCH] feat: add Prisma schema --- packages/database/prisma/schema.prisma | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 packages/database/prisma/schema.prisma diff --git a/packages/database/prisma/schema.prisma b/packages/database/prisma/schema.prisma new file mode 100644 index 0000000..2cbf8c8 --- /dev/null +++ b/packages/database/prisma/schema.prisma @@ -0,0 +1,50 @@ +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +generator client { + provider = "prisma-client-js" +} + +model Generation { + id String @id @default(cuid()) + repoUrl String + repoName String + commitHash String + status Status @default(QUEUED) + progress Int @default(0) + result Json? + error String? + costUsd Float? + duration Int? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userId String? + user User? @relation(fields: [userId], references: [id]) + viewCount Int @default(0) + + @@unique([repoUrl, commitHash]) + @@index([repoUrl]) + @@index([status]) +} + +model User { + id String @id @default(cuid()) + githubId String @unique + login String + email String? + avatarUrl String? + createdAt DateTime @default(now()) + generations Generation[] +} + +enum Status { + QUEUED + CLONING + PARSING + GENERATING + RENDERING + COMPLETED + FAILED +}