迁移:将DB变更记录SQL文件移动到sql目录下

This commit is contained in:
2026-01-13 10:05:32 +08:00
parent cb268fe26d
commit ebd2e8aa75
131 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
-- 检查并添加手术指征字段
-- 执行时间2025-01-06
-- 说明:修复手术指征字段无法保存或展示的问题
-- 1. 检查surgery_indication字段是否存在
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'cli_surgery'
AND column_name = 'surgery_indication'
) THEN
-- 字段不存在,添加该字段
ALTER TABLE cli_surgery ADD COLUMN surgery_indication TEXT;
-- 添加字段注释
COMMENT ON COLUMN cli_surgery.surgery_indication IS '手术指征';
RAISE NOTICE '已添加 surgery_indication 字段到 cli_surgery 表';
ELSE
RAISE NOTICE 'surgery_indication 字段已存在于 cli_surgery 表';
END IF;
END $$;
-- 2. 验证字段是否添加成功
SELECT
column_name,
data_type,
is_nullable,
column_default,
character_maximum_length
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'cli_surgery'
AND column_name = 'surgery_indication';
-- 3. 查看最近的手术记录,检查surgery_indication字段是否有数据
SELECT
id,
surgery_no,
surgery_name,
surgery_indication,
create_time
FROM cli_surgery
WHERE delete_flag = '0'
ORDER BY create_time DESC
LIMIT 5;
-- 4. 更新说明
-- 手术指征字段已添加,可以正常保存和展示数据
-- 该字段为TEXT类型,可以存储较长的文本内容