-- 2026-10-29:商城管理一期:客户商品库可见/上下架与描述。 -- 所有 tenant schema + tenant_template;幂等;不改录单/订单行为。 DO $$ DECLARE sch text; BEGIN FOR sch IN SELECT nspname FROM pg_namespace WHERE nspname = 'tenant_template' OR nspname LIKE 'tenant\_%' LOOP -- 历史/空 tenant 可能没有 customer_skus;跳过而不是让整个迁移事务因 42P01 回滚 IF EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_schema = sch AND table_name = 'customer_skus' ) THEN EXECUTE format( 'ALTER TABLE %I.customer_skus ADD COLUMN IF NOT EXISTS is_listed BOOLEAN NOT NULL DEFAULT true', sch ); EXECUTE format( 'ALTER TABLE %I.customer_skus ADD COLUMN IF NOT EXISTS description TEXT', sch ); END IF; END LOOP; END $$;