Files
SupplierSystem/migrations/20261060_customer_sku_remarks_disable_rls.sql
T
Ubuntu 5fa2bbfd55
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
fix(audit-20261019): T1-T9 审计修复、存储归属与审计日志列宽
- T1 资金/库存/报价/自采 P1(BIZ-1/2/3/4/10/13/14)
- T2 主系统反向事件墓碑/改派/孤儿处理(BIZ-6/8/9)
- T3 选分公司 ticket、trust proxy、角色权限收口(SEC-2/3/4)
- T4 缺列/RLS/tenant 名单/FK/迁移执行器(DATA-1..8)
- T5 401 登出/分页/映射口径/blob/ZIP 中文名(FE-1..4/BIZ-15)
- T6 测试脚本目标守卫/config fail-fast/容器配置(OPS-2..8)
- T7 前后端测试与 lint 门禁清零
- T8 应付卡片按关联订单日(口径 A)
- T9 存储对象全链路归属校验、敏感列禁写、审计 target_id 超长修复
2026-10-19 16:16:51 +08:00

34 lines
1.5 KiB
SQL
Raw 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.
-- T4 / DATA-1(2026-10-19,用户批准方案 B):customer_sku_remarks 统一关闭 RLS。
--
-- 背景:该表**没有 branch_code 列**,RLS 无法表达"分公司隔离";但 public / legacy_public /
-- tenant_br001 / tenant_template 开了 RLS 且 0 条 policy ⇒ BR001 经 /api/data 网关读 0 行、
-- INSERT 被拒(功能坏),而 tenant_br002(关 RLS)正常。
--
-- 决策(D9-B):对齐 br002,对**所有已开启 RLS 的 schema** 执行 DISABLE ROW LEVEL SECURITY;
-- 隔离依赖 schema(每个租户独立 schema,连接 `search_path` 由租户上下文设置),
-- 与"含 branch_code 的表才上租户 RLS"策略一致。详见
-- docs/design/20261019-customer-sku-remarks-rls.md。
--
-- 幂等:只对 relrowsecurity=true 的 schema 执行;重复运行 no-op。
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN
SELECT n.nspname AS schema_name
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = 'customer_sku_remarks'
AND c.relkind = 'r'
AND c.relrowsecurity = true
ORDER BY n.nspname
LOOP
EXECUTE format('ALTER TABLE %I.customer_sku_remarks DISABLE ROW LEVEL SECURITY', r.schema_name);
RAISE NOTICE 'customer_sku_remarks RLS disabled on % (D9-B: no branch_code, isolation by schema)', r.schema_name;
END LOOP;
END $$;
COMMENT ON TABLE public.customer_sku_remarks IS
'客户商品备注:无 branch_code,租户隔离依赖 schema(RLS 有意关闭,见 docs/design/20261019-customer-sku-remarks-rls.md)';