assetflow/prisma/schema.prisma

108 lines
2.7 KiB
Plaintext
Raw Normal View History

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
2023-05-06 20:30:32 +02:00
// https://github.com/pantharshit00/prisma-docs-generator
generator docs {
provider = "node node_modules/prisma-docs-generator"
output = "../docs"
2023-05-06 20:30:32 +02:00
}
// https://github.com/notiz-dev/prisma-dbml-generator
// Viewer: https://dbdiagram.io/d
generator dbml {
provider = "prisma-dbml-generator"
output = "../docs"
outputName = "schema.dbml"
projectName = "AssetFlow"
}
2023-05-15 00:21:53 +02:00
enum itemStatus {
normal
borrowed
stolen
lost
}
model Item {
2023-05-15 00:21:53 +02:00
id Int @id @unique @default(autoincrement())
SKU String? @unique
amount Int @default(1)
name String
2023-05-15 00:21:53 +02:00
comment String?
status itemStatus @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)?
2023-05-15 00:21:53 +02:00
manufacturer String
category itemCategory? @relation(fields: [categoryId], references: [id])
categoryId Int?
2023-05-20 22:03:39 +02:00
contents Item[] @relation("items") /// Item beinhaltet..
baseItem Item[] @relation("items") /// Item zugehörig zu.
storageLocation StorageLocation? @relation(fields: [storageLocationId], references: [id])
storageLocationId Int?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
importedBy String?
}
model StorageLocation {
id Int @id @default(autoincrement())
name String @unique /// This is our LocationID for external use prefixed with: '%StorageUnit%_'
storageUnit StorageUnit? @relation(fields: [storageUnitId], references: [id])
storageUnitId Int?
Item Item[]
}
/// A StorageUnit is the base and can hold multiple StorageLocations.
model StorageUnit {
2023-05-15 00:21:53 +02:00
id Int @id @default(autoincrement())
name String @unique
2023-05-15 00:21:53 +02:00
contactInfo contactInfo @relation(fields: [contactInfoId], references: [id])
contactInfoId Int
2023-05-15 00:21:53 +02:00
StorageLocation StorageLocation[]
}
2023-05-15 00:21:53 +02:00
model itemCategory {
id Int @id @default(autoincrement())
name String @unique
description String?
Item Item[]
}
/// TODO: Add relationship to StorageUnit, Item and if necessary to StorageLocation.
2023-05-15 00:21:53 +02:00
model contactInfo {
id Int @id @default(autoincrement())
type contactType @default(person)
name String?
lastName String?
street String
houseNumber String
zipCode String
city String
country String
2023-05-15 00:21:53 +02:00
StorageUnit StorageUnit[]
}
2023-05-15 00:21:53 +02:00
enum contactType {
storageUnit
person
customer
company
2023-05-15 00:21:53 +02:00
partner
enemy
}