修复数据库:补齐Kingbase操作日志耗时字段

This commit is contained in:
wangzhibiao committed 2026-09-14 21:41:35 +08:00
1 parent 126147c966
commit 118a55b04e
1 file changed
+17
@@ -0,0 +1,17 @@
-- ==============================================================================
-- RailwaySystem 数据库迁移脚本: 001_sys_oper_log_cost_time.sql
-- 适用数据库: KingbaseES V009R003C018 (schema: public)
-- 执行目标: 为系统操作日志表 sys_oper_log 补齐缺失的 cost_time 字段
-- 字段对齐: Java SysOperLog.costTime (Long) -> BIGINT DEFAULT 0
-- 幂等机制: ADD COLUMN IF NOT EXISTS 语法级存在性保护
-- 数据安全: 零清空、零删表,保留全部历史数据,旧数据默认赋 0
-- ==============================================================================
-- 1. 显式添加 cost_time 字段(若不存在),设置默认值为 0
ALTER TABLE public.sys_oper_log ADD COLUMN IF NOT EXISTS cost_time BIGINT DEFAULT 0;
-- 2. 设置列注释
COMMENT ON COLUMN public.sys_oper_log.cost_time IS '消耗时间';
-- 3. 对已有存量数据(若为 NULL)补偿初始化为 0
UPDATE public.sys_oper_log SET cost_time = 0 WHERE cost_time IS NULL;