From 22757a16a12e6031d51bc8271872758dc8ca7934 Mon Sep 17 00:00:00 2001 From: TOHAACK Date: Fri, 19 Apr 2024 10:43:09 +0200 Subject: [PATCH] feat: add database schema --- .../reservation-platform/prisma/schema.prisma | 87 +++++++++---------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/packages/reservation-platform/prisma/schema.prisma b/packages/reservation-platform/prisma/schema.prisma index 848c86b..614b63f 100644 --- a/packages/reservation-platform/prisma/schema.prisma +++ b/packages/reservation-platform/prisma/schema.prisma @@ -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[] }