Rails和jsonb类型的"jsonb"不存在

编程入门 行业动态 更新时间:2024-10-28 13:18:14
本文介绍了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"不存在

本文发布于:2023-10-29 02:43:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不存在   类型   Rails   jsonb   quot

发布评论

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

>www.elefans.com

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