cmvr-wms/ruoyi-project/sql/upgrade/018_collaboration_attachment_soft_delete.sql
2026-10-20 15:35:40 +08:00

14 lines
894 B
SQL
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.

-- target-database: cmvr-project-dev
-- 在017之后、发布附件软删除代码之前执行一次;由人工部署执行,应用及MyBatis不自动执行DDL。
-- 所有已有附件默认保留为有效状态;不删除附件记录、MinIO原文件或历史数据库二进制内容。
SET NAMES utf8mb4;
ALTER TABLE pm_collab_attachment
ADD COLUMN deleted TINYINT(1) NOT NULL DEFAULT 0 COMMENT '软删除标记:0正常,1已删除;保留原文件及存储引用',
ADD COLUMN deleted_by BIGINT NULL COMMENT '附件删除人用户ID,仅工作项负责人或工作项创建者可删除',
ADD COLUMN deleted_at BIGINT NULL COMMENT '附件软删除时间(UTC时间戳,微秒)',
ADD CONSTRAINT ck_pm_collab_attachment_delete CHECK(
(deleted=0 AND deleted_by IS NULL AND deleted_at IS NULL)
OR (deleted=1 AND deleted_by IS NOT NULL AND deleted_at IS NOT NULL)
);