feat: add Area and InventoryScan Prisma models + migrations

Office-move inventory kiem ke feature. See docs/asset-license-management.md InventoryScan section for full business rationale (Area vs Seat, why not AssetItem, asset tag/serial nullable).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
toanhoang
2026-08-19 22:06:52 -04:00
co-authored by Claude Sonnet 5
parent e30489297c
commit 3078d9e8c5
4 changed files with 139 additions and 0 deletions
@@ -0,0 +1,40 @@
-- CreateTable
CREATE TABLE "areas" (
"id" UUID NOT NULL,
"name" TEXT NOT NULL,
"team" TEXT,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "areas_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "areas_name_key" ON "areas"("name");
-- CreateTable
CREATE TABLE "inventory_scans" (
"id" UUID NOT NULL,
"category_id" UUID NOT NULL,
"model_id" UUID NOT NULL,
"area_id" UUID,
"assigned_employee_id" UUID,
"specs" JSONB NOT NULL DEFAULT '{}',
"photo_path" TEXT,
"telegram_chat_id" TEXT,
"telegram_message_id" INTEGER,
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "inventory_scans_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "inventory_scans" ADD CONSTRAINT "inventory_scans_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "asset_categories"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "inventory_scans" ADD CONSTRAINT "inventory_scans_model_id_fkey" FOREIGN KEY ("model_id") REFERENCES "asset_models"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "inventory_scans" ADD CONSTRAINT "inventory_scans_area_id_fkey" FOREIGN KEY ("area_id") REFERENCES "areas"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "inventory_scans" ADD CONSTRAINT "inventory_scans_assigned_employee_id_fkey" FOREIGN KEY ("assigned_employee_id") REFERENCES "employees"("id") ON DELETE SET NULL ON UPDATE CASCADE;