feat: add Prisma schema
This commit is contained in:
50
packages/database/prisma/schema.prisma
Normal file
50
packages/database/prisma/schema.prisma
Normal file
@@ -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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user