gpt4 book ai didi

ruby-on-rails - 在 Rails 模式中启用 UUID 的最简单的最低权限方法是什么?

转载 作者:行者123 更新时间:2023-11-29 12:32:49 25 4
gpt4 key购买 nike

我正在处理一个通过 uuid-ossp 扩展使用 UUID 的 Rails 项目。

这是通过在我看来像标准迁移的方式完成的:

class EnableExtensions < ActiveRecord::Migration
def change
enable_extension 'plpgsql'
enable_extension 'uuid-ossp' if Rails.env.development? || Rails.env.test?
end
end

但是,使用它需要我手动四处走动并设置扩展以使用每个数据库的 postgres super 用户启用:

-- enable_extension("uuid-ossp")
rake aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied to create extension "uuid-ossp"
HINT: Must be superuser to create this extension.
: CREATE EXTENSION IF NOT EXISTS "uuid-ossp"

我不会授予我的用户或 Rails 项目用户对我的任何数据库的 super 用户权限——这似乎不是一个好习惯。那么我应该怎么做呢?

备注:this question's accepted answer doesn't answer the larger question in the title .

最佳答案

显然 https://github.com/dimitri/pgextwlist将允许您将扩展列入白名单,而无需授予 super 用户权限。

发现为 answer Why can only a superuser CREATE EXTENSION hstore, but not on Heroku?

关于ruby-on-rails - 在 Rails 模式中启用 UUID 的最简单的最低权限方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37126447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com