namespace Admin.NET.Plugin.AiDOP.Entity.S6; /// /// S6-LEGACY-SNAPSHOT-MIGRATION-1:S6 存量运行中实例的审批权威快照迁移留证。 /// /// 为什么必须留证ApprovalFlowInstance 没有 version、没有 checksum、 /// 没有并发令牌,UpdateTime 也不是 DB 自动列 —— 裸 UPDATE 之后 /// 无法证明改过什么、为什么改、改前是什么。而 FlowJsonSnapshot 同时是 /// 通用审批中心渲染历史流程图的数据源(FlowInstanceService 对外暴露 → /// 前端 center/index.vueApprovalPanel.vue 消费)。 /// 没有这张表,这就是一次无法解释的静默改写。 /// /// AdoS8ApprovalFlowRepairLog 的关键差异:本表 append-only。 /// S8 那张表每轮 DELETE FROM ... WHERE true 后整体重写(它描述的是「最近一次对账看到了什么」), /// 迁移留证不能是这种语义 —— 迁移是**一次性历史事件**,记录一旦写下就不允许被后续运行抹掉, /// 否则回滚依据会随时间消失。故本表独立建立,不复用 S8 那张。 /// /// 幂等不依赖本表。「是否已迁」的判据是快照自身内容(Role 节点的 approverIds /// 是否还存在纯数字 token),不是「本表里有没有这条 InstanceId」—— /// 留证一旦丢失就重复改写,是 S8 先例踩过的坑。 /// [SugarTable("ado_s6_flow_authority_migration_log", "S6 存量流程审批权威迁移留证(append-only)")] public class AdoS6FlowAuthorityMigrationLog { [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true, ColumnDataType = "bigint")] public long Id { get; set; } /// 迁移批次标识,同一次执行的所有记录共用,便于整批回滚定位。 [SugarColumn(ColumnName = "migration_batch", Length = 64)] public string MigrationBatch { get; set; } = string.Empty; [SugarColumn(ColumnName = "instance_id", ColumnDataType = "bigint")] public long InstanceId { get; set; } [SugarColumn(ColumnName = "biz_type", Length = 64)] public string BizType { get; set; } = string.Empty; [SugarColumn(ColumnName = "biz_id", ColumnDataType = "bigint")] public long BizId { get; set; } /// 由业务实体反查得到,**不取登录用户租户**(实例表自身无 TenantId 列)。 [SugarColumn(ColumnName = "effective_tenant_id", ColumnDataType = "bigint")] public long EffectiveTenantId { get; set; } /// 改前快照全文,逐字保留 —— 第一回滚来源。 [SugarColumn(ColumnName = "before_snapshot", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)] public string? BeforeSnapshot { get; set; } /// 改后快照全文。回滚前用它比对「现值确实是我改成的那样」。 [SugarColumn(ColumnName = "after_snapshot", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)] public string? AfterSnapshot { get; set; } [SugarColumn(ColumnName = "before_md5", Length = 32, IsNullable = true)] public string? BeforeMd5 { get; set; } [SugarColumn(ColumnName = "after_md5", Length = 32, IsNullable = true)] public string? AfterMd5 { get; set; } /// 逐节点映射:node=N2_SUP_REVIEW;1329916010002=>ROLE_S6_IPQC_SUPERVISOR@848643233415237 [SugarColumn(ColumnName = "authority_mapping", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)] public string? AuthorityMapping { get; set; } /// 第二回滚来源:可反查出原始 FlowJson 的 ApprovalFlowVersion 行 Id。 [SugarColumn(ColumnName = "rollback_source", Length = 128, IsNullable = true)] public string? RollbackSource { get; set; } /// 为什么改 / 为什么没改:判据与依据。 [SugarColumn(ColumnName = "reason", Length = 1024, IsNullable = true)] public string? Reason { get; set; } /// APPLIED / SKIPPED_ALREADY_MIGRATED / BLOCKED_TARGET_AUTHORITY / BLOCKED_ROLLBACK_SOURCE / BLOCKED_CONCURRENT_MODIFICATION。 [SugarColumn(ColumnName = "outcome", Length = 48)] public string Outcome { get; set; } = string.Empty; [SugarColumn(ColumnName = "created_at")] public DateTime CreatedAt { get; set; } = DateTime.Now; }