Rails和jsonb类型的"jsonb"不存在 [英] Rails and jsonb type "jsonb" does not exist
本文介绍了Rails和jsonb类型的"jsonb"不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
psql --version
psql (PostgreSQL) 9.4.1
rails -v
Rails 4.2.0
我通过这样的迁移添加了一个jsonb列
I added a jsonb column through migration like that
class AddPreferencesToUsers < ActiveRecord::Migration
def change
add_column :users, :preferences, :jsonb, null: false, default: '{}'
add_index :users, :preferences, using: :gin
end
end
我收到此错误:
PG::UndefinedObject: ERROR: type "jsonb" does not exist
LINE 1: SELECT 'jsonb'::regtype::oid
有什么帮助吗?
推荐答案
环顾四周后,我发现通过运行正确的命令,我的postgresql版本不是9.4
After looking around I discovered that my postgresql version is not 9.4 by running the right command
postgres=# SHOW SERVER_VERSION;
server_version
----------------
9.1
所以我只需要将我的postgresql升级到9.4.
So I had simply to upgrade my postgresql to 9.4.
按照我这篇文章的方式进行升级,我觉得非常方便.
By the way I followed this article to do the upgrading which I found very handy.
现在:
postgres=# SHOW SERVER_VERSION;
server_version
----------------
9.4.1
希望这对处于相同情况的人有所帮助.
Hope this help someone in the same situation.
这篇关于Rails和jsonb类型的"jsonb"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文