Added some prisma schema changes. (untested)

- Not fully implemented yet.
- Renamed ToDo -> TODO
This commit is contained in:
Leon Meier 2023-05-14 13:33:15 +02:00
parent 75a5580366
commit 6344134a9e
3 changed files with 43 additions and 16 deletions

View File

@ -33,17 +33,24 @@ enum Status {
} }
model Item { model Item {
id Int @id @default(autoincrement()) id Int @id @unique @default(autoincrement())
SKU String? @unique SKU String? @unique
Amount Int amount Int @default(1)
Comment String?
name String name String
manufacturer String Comment String?
status Status @default(normal) /// TODO: Would it be better to create a separate model for this as well instead of providing several static statuses to choose from(enum)?
manufacturer String /// TODO: Do we need this as a mandatory field? Probably we can add another model for manufacturer.
category Category @relation(fields: [categoryId], references: [id]) category Category @relation(fields: [categoryId], references: [id])
categoryId Int categoryId Int
status Status
StorageLocation StorageLocation? @relation(fields: [storageLocationId], references: [id]) items Item[] @relation("items") /// Item beinhaltet..
baseItem Item[] @relation("items") /// Item zugehörig zu.
storageLocation StorageLocation? @relation(fields: [storageLocationId], references: [id])
storageLocationId Int? storageLocationId Int?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
importedBy String? importedBy String?
@ -51,12 +58,13 @@ model Item {
model StorageLocation { model StorageLocation {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String @unique name String @unique /// This is our LocationID for external use prefixed with: '%StorageUnit%_'
storageUnit StorageUnit? @relation(fields: [storageUnitId], references: [id]) storageUnit StorageUnit? @relation(fields: [storageUnitId], references: [id])
storageUnitId Int? storageUnitId Int?
Item Item[] Item Item[]
} }
/// A StorageUnit is the base and can hold multiple StorageLocations.
model StorageUnit { model StorageUnit {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String name String
@ -74,3 +82,22 @@ model Category {
description String? description String?
Item Item[] Item Item[]
} }
/// TODO: Add relationship to StorageUnit, Item and if necessary to StorageLocation.
model Owner {
id Int @id @default(autoincrement())
type OwnerType @default(person)
name String
lastName String?
street String
houseNumber String
zipCode String
city String
country String
}
enum OwnerType {
person
customer
company
}

View File

@ -54,7 +54,7 @@ export default class config {
} }
// BUG: If file does'nt exist -> fail. // BUG: If file does'nt exist -> fail.
// ToDo: Check for SyntaxError on fileread and ask if the user wants to continue -> overwrite everything. This behavior is currently standard. // TODO: Check for SyntaxError on fileread and ask if the user wants to continue -> overwrite everything. This behavior is currently standard.
/* /*

View File

@ -55,7 +55,7 @@ export default (req: Request, res: Response) => {
const promise = prisma.item.create({ const promise = prisma.item.create({
data: { data: {
name: record.name, name: record.name,
Amount: parseInt(record.amount), amount: parseInt(record.amount),
Comment: record.comment, Comment: record.comment,
category: { category: {
connect: { connect: {