Heroku +公寓PG ::错误:错误:函数pg_stat_statements_reset()不存在 [英] Heroku + Apartment PG::Error: ERROR: function pg_stat_statements_reset() does not exist

查看:199
本文介绍了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_stat_statements_reset()不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆