diff --git a/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V41__bug735_add_stopper_id_to_requests.sql b/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V41__bug735_add_stopper_id_to_requests.sql index da7e0dd0f..76463d0c9 100644 --- a/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V41__bug735_add_stopper_id_to_requests.sql +++ b/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V41__bug735_add_stopper_id_to_requests.sql @@ -2,8 +2,16 @@ -- 原因:stopper_name 映射到 update_by 字段,签发时 MyBatis-Plus 自动填充导致错误赋值 -- 修复:添加专用 stopper_id 字段,仅在停嘱操作时设置 --- 药品请求表添加停嘱医生ID字段 -ALTER TABLE med_medication_request ADD COLUMN IF NOT EXISTS stopper_id BIGINT; +-- 药品请求表添加停嘱医生ID字段(仅当表存在时) +DO $$ BEGIN + ALTER TABLE med_medication_request ADD COLUMN IF NOT EXISTS stopper_id BIGINT; +EXCEPTION WHEN undefined_table THEN + RAISE NOTICE 'med_medication_request table does not exist, skipping'; +END $$; --- 服务请求表添加停嘱医生ID字段 -ALTER TABLE wor_service_request ADD COLUMN IF NOT EXISTS stopper_id BIGINT; +-- 服务请求表添加停嘱医生ID字段(仅当表存在时) +DO $$ BEGIN + ALTER TABLE wor_service_request ADD COLUMN IF NOT EXISTS stopper_id BIGINT; +EXCEPTION WHEN undefined_table THEN + RAISE NOTICE 'wor_service_request table does not exist, skipping'; +END $$;