添加失败: new row violates row-level security policy for table "demands"
即使您使用管理员账户,PostgreSQL的行级安全策略(RLS)也可能限制了对表的操作。这通常是由于:
请尝试以下一种或多种解决方案:
查看表上的现有行级安全策略:
SELECT * FROM pg_policies WHERE tablename = 'demands';
如果是临时操作,可以禁用RLS:
ALTER TABLE demands DISABLE ROW LEVEL SECURITY;
操作完成后记得重新启用:
ALTER TABLE demands ENABLE ROW LEVEL SECURITY;
修改策略,使管理员不受限制:
CREATE POLICY admin_bypass ON demands USING (current_user = 'admin') WITH CHECK (current_user = 'admin');
确认您的管理员账户具有绕过RLS的权限:
SELECT usename, usebypassrls FROM pg_userWHERE usename = CURRENT_USER;