Files
his/sql/迁移记录-DB变更记录/20250104_update_cli_surgery_tenant_id.sql

13 lines
473 B
SQL
Raw Permalink 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.

-- 更新 cli_surgery 表的 tenant_id 字段
-- 创建时间: 2025-01-04
-- 说明: 为已存在的手术记录设置默认租户ID
-- 将所有 tenant_id 为 NULL 的记录设置为默认租户ID1
UPDATE cli_surgery
SET tenant_id = 1
WHERE tenant_id IS NULL;
-- 添加非空约束(可选,根据业务需求决定是否执行)
-- ALTER TABLE cli_surgery ALTER COLUMN tenant_id SET NOT NULL;
-- ALTER TABLE cli_surgery ALTER COLUMN tenant_id SET DEFAULT 1;