feat: add AssetItem Prisma model + migration

This commit is contained in:
2026-07-31 16:04:01 +07:00
parent 3f6497e2df
commit 09b54f3c6b
2 changed files with 47 additions and 0 deletions
@@ -0,0 +1,18 @@
-- CreateEnum
CREATE TYPE "AssetItemStatus" AS ENUM ('in_stock', 'assigned', 'repair', 'retired');
-- CreateTable
CREATE TABLE "asset_items" (
"id" UUID NOT NULL,
"serial_number" TEXT NOT NULL,
"model" TEXT NOT NULL,
"purchase_date" DATE NOT NULL,
"warranty_end_date" DATE,
"status" "AssetItemStatus" NOT NULL DEFAULT 'in_stock',
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "asset_items_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "asset_items_serial_number_key" ON "asset_items"("serial_number");
+29
View File
@@ -63,6 +63,35 @@ model Employee {
@@map("employees") @@map("employees")
} }
// Fixed, closed set of 4 values tied to the domain (see docs/
// asset-license-management.md's "Data model (sơ bộ)" table) — native
// Postgres enum, same rationale as RequestType above.
enum AssetItemStatus {
in_stock
assigned
repair
retired
}
// Hardware inventory — see docs/asset-license-management.md's "Data model
// (sơ bộ)" table (serial number, model, ngày mua, bảo hành, trạng thái).
// No Vendor/Assignment relation yet — those entities don't exist yet
// (see "Việc còn dở" in CLAUDE.md), so this is a standalone entity for now,
// same starting shape as Employee before Request grew an FK to it.
// warrantyEndDate is nullable: not every asset has known warranty terms at
// intake time (smallest sensible assumption — doesn't block creation).
model AssetItem {
id String @id @default(uuid()) @db.Uuid
serialNumber String @unique @map("serial_number")
model String
purchaseDate DateTime @map("purchase_date") @db.Date
warrantyEndDate DateTime? @map("warranty_end_date") @db.Date
status AssetItemStatus @default(in_stock)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
@@map("asset_items")
}
// Minimal internal auth accounts — NOT company SSO (deliberately ruled out, // Minimal internal auth accounts — NOT company SSO (deliberately ruled out,
// see CLAUDE.md / auth decision notes). A handful of trusted IT staff // see CLAUDE.md / auth decision notes). A handful of trusted IT staff
// accounts, created by hand via scripts/create-user.ts, no self-registration. // accounts, created by hand via scripts/create-user.ts, no self-registration.