Files
SupplierSystem/migrations/20261089_customer_portal_order_customer.sql
Ubuntu b8bbf21599 feat(客户商城): 下单客户账号与小程序商城二期
正常客户开户/停用/重置;order_customer 三重闸;mall-panel 商品、地址、下单;价格/客户由服务端推导;菜单与账户入口修复。
2026-10-28 21:06:36 +08:00

25 lines
1.0 KiB
SQL

-- 2026-10-30:客户自助商城二期:复用 customer_portal_users,新增状态/创建人/更新时间,
-- 并登记 order_customer 角色(不新增账号表)。
DO $$
DECLARE
sch text;
BEGIN
FOR sch IN
SELECT nspname FROM pg_namespace
WHERE nspname = 'tenant_template' OR nspname LIKE 'tenant\_%'
LOOP
IF EXISTS (
SELECT 1 FROM information_schema.tables
WHERE table_schema = sch AND table_name = 'customer_portal_users'
) THEN
EXECUTE format('ALTER TABLE %I.customer_portal_users ADD COLUMN IF NOT EXISTS status INT NOT NULL DEFAULT 1', sch);
EXECUTE format('ALTER TABLE %I.customer_portal_users ADD COLUMN IF NOT EXISTS created_by UUID', sch);
EXECUTE format('ALTER TABLE %I.customer_portal_users ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ', sch);
END IF;
END LOOP;
END $$;
INSERT INTO public.role_definitions (role_code, role_name, is_builtin, sort_order)
VALUES ('order_customer', '下单客户', true, 900)
ON CONFLICT (role_code) DO NOTHING;