站点因更新失败而关闭:创建扩展名“unaccent”的权限被拒绝

通过 Web UI 升级失败,并出现此错误:

INFO -- : > cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate'
discourse@discourse ERROR:  permission denied to create extension "unaccent"
discourse@discourse HINT:  Must be superuser to create this extension.
discourse@discourse STATEMENT:  CREATE EXTENSION IF NOT EXISTS unaccent
rake aborted!
PG::InsufficientPrivilege: ERROR:  permission denied to create extension "unaccent"
HINT:  Must be superuser to create this extension.

很久以前我编辑了我的 app.yml,这可能是导致问题的原因:

templates:
  # 注释掉以解决磁盘空间问题
  #- "templates/postgres.template.yml"
  - "templates/postgres.10.template.yml"

我很久以前就做了这个更改,所以除了那个注释之外,我不记得当时的情况了。

我搁置了这个问题,并通过编辑 app.yml 的版本到 v2.8.0beta8 来尝试恢复到我收到更新错误之前的 discourse 版本,但这失败了:

Pups::ExecError: cd /var/www/discourse & git checkout v2.8.0.beta8 failed with return #<Process::Status: pid 1843 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"code", "cmd"=>["git reset --hard", "git clean -f", "git remote set-branches --add origin main", "git remote set-branches origin $version", "git fetch --depth 1 origin $version", "git checkout $version", "mkdir -p tmp", "chown discourse:www-data tmp", "mkdir -p tmp/pids", "mkdir -p tmp/sockets", "touch tmp/.gitkeep", "mkdir -p                    /shared/log/rails", "bash -c \"touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log\"", "bash -c \"ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log $home/log\"", "bash -c \"mkdir -p           /shared/{uploads,backups}\"", "bash -c \"ln    -s           /shared/{uploads,backups} $home/public\"", "bash -c \"mkdir -p           /shared/tmp/{backups,restores}\"", "bash -c \"ln    -s           /shared/tmp/{backups,restores} $home/tmp\"", "chown -R discourse:www-data /shared/log/rails /shared/uploads /shared/backups /shared/tmp\"", "find public/plugins/ -maxdepth 1 -xtype l -delete"])}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
5b66f706de1a3ce8d78f0ed886669095c1a356efd916cb2ae8b02171367b0a01

所以我认为我需要升级 postgres 从 10,或者降级 discourse 到 2.8.0beta8,但两者都失败了。我该怎么办?

此服务器是如何安装的?

您是否对 Postgres 配置进行了任何更改?

如果您仍在使用 Postgres 10,请尝试在 app.ymlhooks: 部分之后添加以下内容:

afer_postgres:
    - exec: su postgres -c 'psql discourse -c "create extension if not exists unaccent;"'
2 个赞

我们早在 2020 年 就已从 PostgreSQL 10 迁移。我强烈建议您尽快更新。

3 个赞

有什么关于如何做到这一点的指导吗?比撤销那一行 app.yml 更多吗?

我帖子上的链接是关于这方面的指南,但是我们也迁移到了PostgreSQL 13 更新,请关注新的指南。

4 个赞

这为我解决了问题,然后我就可以根据 @Falco 的说明升级 postgres 了。

4 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.