Heroku +公寓PG ::错误:错误:函数pg

编程入门 行业动态 更新时间:2024-10-11 05:29:21
本文介绍了Heroku +公寓PG ::错误:错误:函数pg_stat_statements_reset()不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Rails 4中使用Apartment gem在Heroku上的Postgres 9.3.3中支持多租户。

I use Apartment gem in Rails 4 to support multi-tenancy in Postgres 9.3.3 on Heroku.

Apartment gem创建新租户时发生错误。

An error is occurred when Apartment gem creates a new tenant.

深入调查显示,已创建模式,但内部没有表。

Deep investigation showed that a schema was created, but no tables inside.

Heroku日志显示错误:

Heroku logs showed an error:

PG::Error: ERROR: function pg_stat_statements_reset() does not exist

推荐答案

创建新的模式Postgres试图通过执行功能 pg_stat_statements_reset()

When a new schema is created Postgres is trying to reset stats by executing the function pg_stat_statements_reset()

来重置统计信息,默认情况下,该功能只能由超级用户执行(来自原始文档)。

By default, this function can only be executed by superusers (from original doc).

Heroku没有给您超级用户特权。 因此,您需要禁用扩展pg_stat_statements。

Heroku doesn't give you superuser privileges. So you need to disable extension pg_stat_statements.

解决方案1-直接在数据库中快速快速修复

在架构 public

DROP EXTENSION pg_stat_statements;

解决方案2-通过迁移

1)检查文件 db / schema.rb 。

enable_extension "pg_stat_statements"

2)创建迁移文件

rails g migration DropExtensionPgStatStatements

3)定义self.up方法

3) define self.up method

def self.up disable_extension "pg_stat_statements" end

4)应用迁移

rake db:migrate

5)现在文件 db / schema.rb 不应包含该行

5) Now the file db/schema.rb should not contain that line

6)提交更改(模式和迁移文件)并部署到Heroku

6) Commit changes (schema and migration files) and deploy to Heroku

rake deploy:production:migrations

关于耙任务,请参见 deploy.rake

更多推荐

Heroku +公寓PG ::错误:错误:函数pg

本文发布于:2023-07-21 07:27:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1175431.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   函数   公寓   Heroku   pg

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!