本文介绍了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"不存在
发布评论