Add AssetItem.assetTag, status-aware bulk import, nullable purchaseDate
CI / test (push) Failing after 8s
CI / test (push) Failing after 8s
Prep work for importing a real company ITAM export (613 real assets): - AssetItem.assetTag (nullable, unique) -- company physical tag, was only on InventoryScan (move feature) before, now on the actual asset record. - AssetItem.purchaseDate is now nullable (was required) -- some legacy rows genuinely have no known purchase date. Manual /assets create form still requires it in the HTML input; this only relaxes the DB/import path for historical data. - importAssetItems() accepts a status column now (free-text "In use"/ "In stock"/etc mapped via IMPORT_STATUS_MAP), unlike manual creation which always defaults in_stock -- bulk-imported inventory is usually already deployed, not freshly purchased, so forcing in_stock would misrepresent reality. Hand-written migrations (asset_tag, purchase_date nullable), no Vitest coverage -- same deviation as the rest of this branch, see CLAUDE.md. tsc/lint clean. Actually imported 613/613 real AssetItem rows from the export with 0 errors after this (not committed here -- thats data, not code; see CLAUDE.md for the seeding/import process and whats deliberately out of scope this round: Cost, PO number, employee Assignment).
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
-- Hand-written (same deviation as other 2026-08-2x migrations -- see CLAUDE.md).
|
||||
ALTER TABLE "asset_items" ADD COLUMN "asset_tag" TEXT;
|
||||
CREATE UNIQUE INDEX "asset_items_asset_tag_key" ON "asset_items"("asset_tag");
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Hand-written (same deviation as other 2026-08-2x migrations -- see CLAUDE.md).
|
||||
ALTER TABLE "asset_items" ALTER COLUMN "purchase_date" DROP NOT NULL;
|
||||
+17
-1
@@ -118,9 +118,25 @@ enum AssetItemStatus {
|
||||
model AssetItem {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
serialNumber String @unique @map("serial_number")
|
||||
// Company-assigned physical tag (e.g. "DANLAP001", printed on a sticker
|
||||
// on the device) -- 2026-08-24, added when bulk-importing the real
|
||||
// ServiceNow ITAM export (see docs/asset-license-management.md). Was
|
||||
// only on InventoryScan before (the office-move walk feature); this is
|
||||
// the same concept but on the actual asset record, not a move-day scan.
|
||||
// Nullable (a manually-entered new purchase may not have one yet) but
|
||||
// unique when present -- the real export had 613/613 unique, non-null
|
||||
// tags, same integrity guarantee as serialNumber.
|
||||
assetTag String? @unique @map("asset_tag")
|
||||
modelId String @map("model_id") @db.Uuid
|
||||
model AssetModel @relation(fields: [modelId], references: [id])
|
||||
purchaseDate DateTime @map("purchase_date") @db.Date
|
||||
// Nullable as of 2026-08-24 (was NOT NULL) -- bulk-importing the real
|
||||
// ITAM export, some legacy rows have no known purchase date at all (no
|
||||
// "Order received" value in the source). Manual /assets create form
|
||||
// still requires it (a NEW purchase should always have a known date);
|
||||
// this only relaxes the DB/import path for historical data. Also means
|
||||
// AssetModel.warrantyMonths auto-fill (see createAssetItem()) can't
|
||||
// compute anything for these rows -- warrantyEndDate stays null too.
|
||||
purchaseDate DateTime? @map("purchase_date") @db.Date
|
||||
warrantyEndDate DateTime? @map("warranty_end_date") @db.Date
|
||||
status AssetItemStatus @default(in_stock)
|
||||
purchaseOrderId String? @map("purchase_order_id") @db.Uuid
|
||||
|
||||
Reference in New Issue
Block a user