mirror of
https://github.com/duongcamcute/tech-gadget-manager.git
synced 2026-03-03 02:27:01 +00:00
157 lines
4.4 KiB
Plaintext
157 lines
4.4 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
binaryTargets = ["native", "rhel-openssl-1.0.x", "rhel-openssl-3.0.x", "linux-musl-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
// Sử dụng biến môi trường để có thể cấu hình đường dẫn trong Docker
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Item {
|
|
id String @id @default(uuid())
|
|
name String
|
|
type String
|
|
category String
|
|
specs String
|
|
locationId String?
|
|
location Location? @relation(fields: [locationId], references: [id])
|
|
status String @default("Available")
|
|
|
|
brand String?
|
|
model String?
|
|
color String?
|
|
serialNumber String?
|
|
|
|
purchaseDate DateTime?
|
|
warrantyEnd DateTime?
|
|
purchaseLocation String?
|
|
purchaseUrl String?
|
|
purchasePrice Float? // Added field
|
|
notes String?
|
|
image String?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
lendingRecords LendingRecord[]
|
|
history ItemHistory[]
|
|
attachments Attachment[]
|
|
}
|
|
|
|
model Attachment {
|
|
id String @id @default(uuid())
|
|
itemId String
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
name String
|
|
type String // MIME type or category: image, document, invoice, warranty, other
|
|
url String // File path or URL
|
|
size Int? // File size in bytes
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model ItemHistory {
|
|
id String @id @default(uuid())
|
|
itemId String
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
action String // CREATED, MOVED, LENT, RETURNED, UPDATED
|
|
details String? // e.g., "Moved to Bag 1", "Lent to John"
|
|
timestamp DateTime @default(now())
|
|
}
|
|
|
|
model Location {
|
|
id String @id @default(uuid())
|
|
name String
|
|
type String
|
|
icon String?
|
|
image String? // Base64 WebP ảnh minh họa vị trí
|
|
parentId String?
|
|
parent Location? @relation("LocationHierarchy", fields: [parentId], references: [id])
|
|
children Location[] @relation("LocationHierarchy")
|
|
items Item[]
|
|
}
|
|
|
|
model LendingRecord {
|
|
id String @id @default(uuid())
|
|
itemId String
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
borrowerName String
|
|
borrowDate DateTime @default(now())
|
|
dueDate DateTime?
|
|
returnDate DateTime?
|
|
}
|
|
|
|
model Template {
|
|
id String @id @default(uuid())
|
|
name String
|
|
category String
|
|
config String // JSON string of ItemFormData
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Contact {
|
|
id String @id @default(uuid())
|
|
name String @unique
|
|
phone String?
|
|
notes String?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
|
|
model Brand {
|
|
id String @id @default(uuid())
|
|
name String @unique
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
username String @unique
|
|
password String
|
|
fullName String? // New field
|
|
avatar String? // New field
|
|
theme String @default("default")
|
|
colors String?
|
|
}
|
|
|
|
model ApiKey {
|
|
id String @id @default(uuid())
|
|
name String
|
|
key String @unique
|
|
lastUsed DateTime?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model AuditLog {
|
|
id String @id @default(uuid())
|
|
action String // CREATE, UPDATE, DELETE, LEND, RETURN, LOGIN, EXPORT, IMPORT
|
|
entityType String // Item, Location, User, etc.
|
|
entityId String?
|
|
entityName String? // Human-readable name for display
|
|
details String? // JSON or text details
|
|
userId String?
|
|
userName String? // Store username for historical reference
|
|
ipAddress String?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model WebhookConfig {
|
|
id String @id @default(uuid())
|
|
name String
|
|
url String
|
|
events String // Comma-separated: item.created,item.updated,item.deleted,item.lent,item.returned
|
|
secret String? // Optional secret for signature verification
|
|
active Boolean @default(true)
|
|
lastError String?
|
|
lastRun DateTime?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model ItemType {
|
|
id String @id @default(uuid())
|
|
value String @unique
|
|
label String
|
|
order Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
}
|