feat: add generated code
This commit is contained in:
78
backend/prisma/schema.prisma
Normal file
78
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,78 @@
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
enum MovementKind {
|
||||
Receipt
|
||||
Issue
|
||||
Transfer
|
||||
Adjustment
|
||||
}
|
||||
|
||||
model ProductType {
|
||||
id String @id @default(uuid())
|
||||
name String @unique
|
||||
products Product[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("product_types")
|
||||
}
|
||||
|
||||
model Product {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
productType ProductType @relation(fields: [productTypeId], references: [id])
|
||||
productTypeId String
|
||||
parent Product? @relation("ProductHierarchy", fields: [parentId], references: [id])
|
||||
parentId String?
|
||||
children Product[] @relation("ProductHierarchy")
|
||||
stockStatus StockStatus?
|
||||
lines StockMovementLine[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("products")
|
||||
}
|
||||
|
||||
model StockStatus {
|
||||
product Product @relation(fields: [productId], references: [id])
|
||||
productId String @id @unique
|
||||
quantity Decimal @default(0)
|
||||
inStock Boolean @default(false)
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@map("stock_statuses")
|
||||
}
|
||||
|
||||
model StockMovement {
|
||||
id String @id @default(uuid())
|
||||
documentDate DateTime @db.Date
|
||||
kind MovementKind
|
||||
lines StockMovementLine[]
|
||||
comment String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("stock_movements")
|
||||
}
|
||||
|
||||
model StockMovementLine {
|
||||
id String @id @default(uuid())
|
||||
product Product @relation(fields: [productId], references: [id])
|
||||
productId String
|
||||
quantity Decimal
|
||||
inStock Boolean
|
||||
movement StockMovement @relation(fields: [movementId], references: [id])
|
||||
movementId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([movementId, productId])
|
||||
@@map("stock_movement_lines")
|
||||
}
|
||||
Reference in New Issue
Block a user