140 lines
3.6 KiB
Plaintext
140 lines
3.6 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Location {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
description String?
|
|
categories Category[]
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
@@map("locations")
|
|
}
|
|
|
|
model Category {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
location Location @relation(fields: [location_id], references: [id])
|
|
location_id Int
|
|
items Item[]
|
|
boxes Box[]
|
|
userCategoryAccess UserCategoryAccess[]
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("categories")
|
|
}
|
|
|
|
model Item {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
code String?
|
|
description String?
|
|
quantity Int @default(0)
|
|
category Category @relation(fields: [category_id], references: [id])
|
|
category_id Int
|
|
box_items BoxItem[]
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
@@map("items")
|
|
}
|
|
|
|
model Box {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
category Category @relation(fields: [category_id], references: [id])
|
|
category_id Int
|
|
items BoxItem[]
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("boxes")
|
|
}
|
|
|
|
model BoxItem {
|
|
id Int @id @default(autoincrement())
|
|
box Box @relation(fields: [box_id], references: [id])
|
|
box_id Int
|
|
item Item @relation(fields: [item_id], references: [id])
|
|
item_id Int
|
|
quantity Int
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("box_items")
|
|
}
|
|
|
|
model Role {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
description String?
|
|
users User[]
|
|
permissions RolePermission[]
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("roles")
|
|
}
|
|
|
|
model Permission {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
description String?
|
|
roles RolePermission[]
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("permissions")
|
|
}
|
|
|
|
model RolePermission {
|
|
id Int @id @default(autoincrement())
|
|
role Role @relation(fields: [role_id], references: [id])
|
|
role_id Int
|
|
permission Permission @relation(fields: [permission_id], references: [id])
|
|
permission_id Int
|
|
created_at DateTime @default(now())
|
|
|
|
@@unique([role_id, permission_id])
|
|
@@map("role_permissions")
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
password_hash String
|
|
role Role @relation(fields: [role_id], references: [id])
|
|
role_id Int
|
|
is_active Boolean @default(true)
|
|
last_login DateTime?
|
|
categoryAccess UserCategoryAccess[]
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model UserCategoryAccess {
|
|
id Int @id @default(autoincrement())
|
|
user User @relation(fields: [user_id], references: [id])
|
|
user_id Int
|
|
category Category @relation(fields: [category_id], references: [id])
|
|
category_id Int
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("user_category_access")
|
|
}
|
|
|
|
model YearEndTransfer {
|
|
id Int @id @default(autoincrement())
|
|
year Int
|
|
completed_at DateTime
|
|
status String
|
|
error_message String?
|
|
created_at DateTime @default(now())
|
|
|
|
@@map("year_end_transfers")
|
|
}
|