feat(P17B-1,P17B-2): 补齐采购预算闭环与归档模型接口
这个提交包含在:
@@ -0,0 +1,27 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "purchase_order_archives" (
|
||||
"id" UUID NOT NULL,
|
||||
"purchase_request_id" UUID NOT NULL,
|
||||
"po_no" TEXT NOT NULL,
|
||||
"contract_no" TEXT,
|
||||
"archived_files" JSONB,
|
||||
"archived_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"archived_by" UUID NOT NULL,
|
||||
|
||||
CONSTRAINT "purchase_order_archives_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "purchase_order_archives_purchase_request_id_key" ON "purchase_order_archives"("purchase_request_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_purchase_order_archives_archived_by" ON "purchase_order_archives"("archived_by");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_purchase_order_archives_archived_at" ON "purchase_order_archives"("archived_at");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "purchase_order_archives" ADD CONSTRAINT "purchase_order_archives_purchase_request_id_fkey" FOREIGN KEY ("purchase_request_id") REFERENCES "purchase_requests"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "purchase_order_archives" ADD CONSTRAINT "purchase_order_archives_archived_by_fkey" FOREIGN KEY ("archived_by") REFERENCES "employees"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
+22
-3
@@ -229,9 +229,10 @@ model Employee {
|
||||
leave_requests LeaveRequest[]
|
||||
leave_ledgers LeaveLedger[]
|
||||
owned_cost_centers CostCenter[] @relation("CostCenterOwner")
|
||||
purchase_requests_applicant PurchaseRequest[] @relation("PurchaseRequestApplicant")
|
||||
purchase_requests_submitted PurchaseRequest[] @relation("PurchaseRequestSubmitter")
|
||||
purchase_attachments_uploaded PurchaseAttachment[] @relation("PurchaseAttachmentUploader")
|
||||
purchase_requests_applicant PurchaseRequest[] @relation("PurchaseRequestApplicant")
|
||||
purchase_requests_submitted PurchaseRequest[] @relation("PurchaseRequestSubmitter")
|
||||
purchase_attachments_uploaded PurchaseAttachment[] @relation("PurchaseAttachmentUploader")
|
||||
purchase_order_archives PurchaseOrderArchive[] @relation("PurchaseOrderArchiveArchivedBy")
|
||||
|
||||
owned_invoices InvoicePool[] @relation("InvoiceOwner")
|
||||
uploaded_invoices InvoicePool[] @relation("InvoiceUploader")
|
||||
@@ -584,6 +585,7 @@ model PurchaseRequest {
|
||||
|
||||
items PurchaseRequestItem[]
|
||||
attachments PurchaseAttachment[]
|
||||
order_archive PurchaseOrderArchive?
|
||||
workflow_instances WorkflowInstance[]
|
||||
|
||||
@@index([applicant_id, status, updated_at], map: "idx_purchase_requests_applicant_status_updated")
|
||||
@@ -637,6 +639,23 @@ model PurchaseAttachment {
|
||||
@@map("purchase_attachments")
|
||||
}
|
||||
|
||||
model PurchaseOrderArchive {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
purchase_request_id String @unique @db.Uuid
|
||||
po_no String
|
||||
contract_no String?
|
||||
archived_files Json?
|
||||
archived_at DateTime @default(now())
|
||||
archived_by String @db.Uuid
|
||||
|
||||
purchase_request PurchaseRequest @relation(fields: [purchase_request_id], references: [id], onDelete: Cascade)
|
||||
archived_by_employee Employee @relation("PurchaseOrderArchiveArchivedBy", fields: [archived_by], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([archived_by], map: "idx_purchase_order_archives_archived_by")
|
||||
@@index([archived_at], map: "idx_purchase_order_archives_archived_at")
|
||||
@@map("purchase_order_archives")
|
||||
}
|
||||
|
||||
model ReimbursementForm {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
form_number String? @unique
|
||||
|
||||
在新工单中引用
屏蔽一个用户