feat: add database schema
This commit is contained in:
parent
f8e3b2e299
commit
22757a16a1
@ -7,67 +7,66 @@ generator client {
|
|||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "sqlite"
|
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")
|
url = env("DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
model Post {
|
// MYP Schema
|
||||||
id Int @id @default(autoincrement())
|
model Printer {
|
||||||
name String
|
id Int @id @unique
|
||||||
createdAt DateTime @default(now())
|
name String
|
||||||
updatedAt DateTime @updatedAt
|
description String
|
||||||
|
status Int
|
||||||
createdBy User @relation(fields: [createdById], references: [id])
|
created_at DateTime
|
||||||
createdById String
|
updated_at DateTime
|
||||||
|
PrintJob PrintJob[]
|
||||||
@@index([name])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 {
|
model Account {
|
||||||
id String @id @default(cuid())
|
id String @id @unique
|
||||||
userId String
|
userId String
|
||||||
type String
|
type String
|
||||||
provider String
|
provider String
|
||||||
providerAccountId String
|
providerAccountId String
|
||||||
refresh_token String? // @db.Text
|
refresh_token String
|
||||||
access_token String? // @db.Text
|
access_token String
|
||||||
expires_at Int?
|
expires_at Int
|
||||||
token_type String?
|
token_type String
|
||||||
scope String?
|
scope String
|
||||||
id_token String? // @db.Text
|
id_token String
|
||||||
session_state String?
|
session_state String
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
User User @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
@@unique([provider, providerAccountId])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model Session {
|
model Session {
|
||||||
id String @id @default(cuid())
|
id String @id @unique
|
||||||
sessionToken String @unique
|
sessionToken String @unique
|
||||||
userId String
|
userId String
|
||||||
expires DateTime
|
expires DateTime
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
User User @relation(fields: [userId], references: [id])
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id @default(cuid())
|
id String @id
|
||||||
name String?
|
name String
|
||||||
email String? @unique
|
email String @unique
|
||||||
emailVerified DateTime?
|
role String
|
||||||
image String?
|
Account Account[]
|
||||||
accounts Account[]
|
Session Session[]
|
||||||
sessions Session[]
|
PrintJob PrintJob[]
|
||||||
posts Post[]
|
|
||||||
}
|
|
||||||
|
|
||||||
model VerificationToken {
|
|
||||||
identifier String
|
|
||||||
token String @unique
|
|
||||||
expires DateTime
|
|
||||||
|
|
||||||
@@unique([identifier, token])
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user