fix: retrofit AssetItem.model to modelId FK

AssetItem.model was a free-text string with no referential integrity.
Now a required FK to AssetModel, mirroring the Request.employeeId and
License.vendorId retrofit precedent (no backfill needed, no real
AssetItem data existed).
This commit is contained in:
toanhoang
2026-08-02 21:07:12 -04:00
parent d280279322
commit 2a5792df67
5 changed files with 169 additions and 46 deletions
+2 -2
View File
@@ -22,11 +22,11 @@ export async function POST(request: Request): Promise<NextResponse> {
return NextResponse.json({ error: "Request body must be a JSON object" }, { status: 400 });
}
const { serialNumber, model, purchaseDate, warrantyEndDate, purchaseOrderId } =
const { serialNumber, modelId, purchaseDate, warrantyEndDate, purchaseOrderId } =
body as Record<string, unknown>;
const validation = validateCreateAssetItemInput({
serialNumber,
model,
modelId,
purchaseDate,
warrantyEndDate,
purchaseOrderId,