From e5f7948c469a9a42d3eaa9663f9a68e230701bd1 Mon Sep 17 00:00:00 2001 From: minie4 Date: Sun, 1 May 2022 20:58:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Add=20database=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/index.js | 2 +- server/prisma/schema.prisma | 50 ++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/server/index.js b/server/index.js index b4589cb..12cbe36 100644 --- a/server/index.js +++ b/server/index.js @@ -6,7 +6,7 @@ const prisma = new Prisma.PrismaClient(); const port = process.send.PORT || 3000; app.get("/", async (_req, res) => { - const result = await prisma.test.findMany(); + const result = await prisma.substitution.findMany(); res.send(result); }); diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index 474c38e..b0eef5d 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -7,7 +7,49 @@ datasource db { url = env("DATABASE_URL") } -model test { - key String @id - value String -} \ No newline at end of file +model Timetable { + id Int @id @unique @default(autoincrement()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + class String + validFrom DateTime @default(now()) + validUntil DateTime? + data Json +} + +model Substitution { + id Int @id @unique @default(autoincrement()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + class String[] + date DateTime + type String + lesson Int + changedTeacher String? + changedRoom String? + changedSubject String? + removed Boolean @default(false) + + SubstitutionChange SubstitutionChange[] +} + +model SubstitutionChange { + id Int @id @unique @default(autoincrement()) + createdAt DateTime @default(now()) + substitution Substitution @relation(fields: [substitutionId], references: [id]) + substitutionId Int + type String + changes Json? + parseEvent ParseEvent @relation(fields: [parseEventId], references: [id]) + parseEventId Int +} + +model ParseEvent { + id Int @id @unique @default(autoincrement()) + createdAt DateTime @default(now()) + logFile String + originalData String + duration Int + + SubstitutionChange SubstitutionChange[] +}