feat: add database schema
This commit is contained in:
parent
f8e3b2e299
commit
22757a16a1
@ -7,67 +7,66 @@ generator client {
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
// NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below
|
||||
// Further reading:
|
||||
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
|
||||
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Post {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
createdBy User @relation(fields: [createdById], references: [id])
|
||||
createdById String
|
||||
|
||||
@@index([name])
|
||||
// MYP Schema
|
||||
model Printer {
|
||||
id Int @id @unique
|
||||
name String
|
||||
description String
|
||||
status Int
|
||||
created_at DateTime
|
||||
updated_at DateTime
|
||||
PrintJob PrintJob[]
|
||||
}
|
||||
|
||||
// Necessary for Next auth
|
||||
model PrintJob {
|
||||
id Int @id @unique
|
||||
printer_id Int
|
||||
user_id String
|
||||
start_at DateTime
|
||||
duration_in_minutes Int
|
||||
comments String
|
||||
aborted Boolean @default(false)
|
||||
abort_reason String
|
||||
created_at DateTime
|
||||
updated_at DateTime
|
||||
Printer Printer @relation(fields: [printer_id], references: [id])
|
||||
User User @relation(fields: [user_id], references: [id])
|
||||
}
|
||||
|
||||
// NextAuth Schema
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
id String @id @unique
|
||||
userId String
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String? // @db.Text
|
||||
access_token String? // @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? // @db.Text
|
||||
session_state String?
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
refresh_token String
|
||||
access_token String
|
||||
expires_at Int
|
||||
token_type String
|
||||
scope String
|
||||
id_token String
|
||||
session_state String
|
||||
User User @relation(fields: [userId], references: [id])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
id String @id @unique
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
User User @relation(fields: [userId], references: [id])
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
posts Post[]
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
id String @id
|
||||
name String
|
||||
email String @unique
|
||||
role String
|
||||
Account Account[]
|
||||
Session Session[]
|
||||
PrintJob PrintJob[]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user