我正在尝试在 Heroku 上的新 Postgres 9 共享数据库中使用 contrib 模块。更具体地说,是 pg_trgm 和 fuzzystrmatch 模块。在documentation它说
In addition, many complimentary extensions are available such as fuzzystrmatch, pg_trgm, and unaccent.
我似乎找不到任何关于如何在共享 Heroku 数据库上实际启用这些模块的文档。 请参阅下面的答案。
注意:
我尝试通过连接到数据库来添加它们
heroku pg:psql HEROKU_POSTGRESQL_BROWN
正在运行
create extension pg_trgm
create extension fuzzystrmatch
但在尝试使用它之后
SELECT levenshtein('tests', 'test');
还是说
ERROR: function levenshtein(unknown, unknown) does not existLINE 1: SELECT levenshtein('tests', 'test');
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
有人知道为什么会这样吗?
最佳答案
找到答案 here在搜索 Stack Overflow 时。不知道为什么它没有出现在我的任何谷歌搜索中。如果其他人使用相同的措辞来搜索此问题,则将问题留在这里。
要启用模块,您需要按如下方式将它们添加到迁移中:
def up
execute "create extension fuzzystrmatch"
execute "create extension pg_trgm"
end
关于ruby-on-rails - 如何在 Heroku Postgres 数据库上启用 contrib 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10752456/