我们正在使用迁移(通过 JavaScript 中的 Sequelize)来维护对数据库的更改。我需要添加 CREATE EXTENSION
调用,但由于我以数据库创建者身份运行,而不是 super 用户,因此我收到创建扩展的权限被拒绝
。
有没有办法修改单个数据库的安全性以允许用户通过迁移文件安装扩展? IOW,当我创建“裸”数据库并应用权限时,我可以将安全性设置为允许特定用户的 CREATE EXTENSION
和 DROP EXTENSION
吗?
最佳答案
否,CREATE ROLE 没有设置用于精细的CREATE/DROP EXTENSION
控制。我认为,这取决于您使用的扩展名,但您基于 documentation :
Loading an extension requires the same privileges that would be required to create its component objects. For most extensions this means superuser or database owner privileges are needed. The user who runs CREATE EXTENSION becomes the owner of the extension for purposes of later privilege checks, as well as the owner of any objects created by the extension's script.
我在使用 pg_trgm
扩展时遇到了同样的问题,但即使将角色设置为数据库所有者也无法解决该问题。
关于postgresql - 通过迁移在 PostgreSQL 数据库中安装扩展而无需 super 用户角色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32341664/