-- ============================================================================= -- 报废审批流 + 按单报废(镜像 借库/出库 审批框架) -- 1) 新表 scrap_approval(申请单) -- 2) trans_scrap 增加 scrap_request_no,关联申请单号 -- 执行: docker exec -i inventory_db psql -U test -d inventory_system < 本文件 -- ============================================================================= BEGIN; CREATE TABLE IF NOT EXISTS scrap_approval ( id SERIAL PRIMARY KEY, request_no varchar(100) UNIQUE NOT NULL, applicant_id integer NOT NULL, remark text, status integer NOT NULL DEFAULT 0, -- 0待审 1已通过(待执行) 2驳回 3已执行 allowed_approvers text, actual_approver_id integer, approved_at timestamptz, reject_reason text, items_json text NOT NULL, executed_at timestamptz, executor_name varchar(100), created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now() ); CREATE INDEX IF NOT EXISTS ix_scrap_approval_status ON scrap_approval(status); CREATE INDEX IF NOT EXISTS ix_scrap_approval_applicant ON scrap_approval(applicant_id); ALTER TABLE trans_scrap ADD COLUMN IF NOT EXISTS scrap_request_no varchar(100); CREATE INDEX IF NOT EXISTS ix_trans_scrap_req_no ON trans_scrap(scrap_request_no); COMMIT;