Files
KCGL/db_migrations/add_scrap_approval.sql
yueli 3d8fb198c5 feat(scrap): 报废审批流 DB 迁移(建表 + 权限码)
- scrap_approval 表(申请单,items_json 携带 source_table+stock_id 精准实物)
- trans_scrap 增加 scrap_request_no 关联申请单
- 注册权限码 scrap_apply / scrap_approval / scrap_execute 并按现有报废角色授予
2026-09-10 09:46:52 +08:00

32 lines
1.4 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =============================================================================
-- 报废审批流 + 按单报废(镜像 借库/出库 审批框架)
-- 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;