-- ============================================================ -- E2E 测试运营账号 seed(幂等,CI 与本机通用) -- -- 为什么需要: -- 迁移里只有 roles / permissions 的种子,**没有任何 operator 账号**。 -- 全新库起栈后一个运营账号都没有,E2E 无法登录,operator 侧链路 -- (权限矩阵、代登记、审核队列)全部无法验证。本脚本把"可自举" -- 做成基建的一部分,而不是依赖某台机器上手工创建的遗留账号。 -- -- 用法(密码由环境变量注入,不入库明文、不进版本库): -- psql -v pwd="$E2E_OPERATOR_PASSWORD" -f seed_e2e_operators.sql -- -- 幂等:全部走 ON CONFLICT DO NOTHING,可重复执行。 -- ============================================================ CREATE EXTENSION IF NOT EXISTS pgcrypto; -- 账号:密码相同($pwd),角色不同,用于验证权限隔离(INV-012/013/019 等) INSERT INTO operators (id, name, username, password_hash, status) VALUES ('e2e00000-0000-0000-0000-000000000001', 'E2E 超级管理员', 'e2e_admin', crypt(:'pwd', gen_salt('bf', 8)), 'active'), ('e2e00000-0000-0000-0000-000000000002', 'E2E 平台管理员', 'e2e_platform', crypt(:'pwd', gen_salt('bf', 8)), 'active'), ('e2e00000-0000-0000-0000-000000000003', 'E2E 婚恋咨询师', 'e2e_counselor', crypt(:'pwd', gen_salt('bf', 8)), 'active'), ('e2e00000-0000-0000-0000-000000000004', 'E2E 服务站运营', 'e2e_station', crypt(:'pwd', gen_salt('bf', 8)), 'active'), ('e2e00000-0000-0000-0000-000000000005', 'E2E 公益红娘', 'e2e_matchmaker', crypt(:'pwd', gen_salt('bf', 8)), 'active'), ('e2e00000-0000-0000-0000-000000000006', 'E2E 内容编辑', 'e2e_content', crypt(:'pwd', gen_salt('bf', 8)), 'active') ON CONFLICT (username) DO NOTHING; -- 角色绑定(role id 取自 V015 seed) -- super_admin / platform_admin INSERT INTO operator_roles (operator_id, role_id) VALUES ('e2e00000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000001'), ('e2e00000-0000-0000-0000-000000000002', '00000000-0000-0000-0000-000000000002'), -- counselor ('e2e00000-0000-0000-0000-000000000003', '00000000-0000-0000-0000-000000000011'), -- service_station_operator ('e2e00000-0000-0000-0000-000000000004', '00000000-0000-0000-0000-000000000010'), -- matchmaker ('e2e00000-0000-0000-0000-000000000005', '00000000-0000-0000-0000-000000000005'), -- content_editor ('e2e00000-0000-0000-0000-000000000006', '00000000-0000-0000-0000-000000000013') ON CONFLICT (operator_id, role_id) DO NOTHING;