我从与之合作的人那里分叉了一个仓库,而我只是想使我的开发环境正常运行。其中一个迁移具有json
属性,我们在开发和生产中都使用Postgres:
class CreateExams < ActiveRecord::Migration
def change
create_table :exams do |t|
t.belongs_to :user
t.json :exam
t.timestamps
end
end
end
development:
adapter: postgresql
database: examgen_development
host: localhost
运行时rake db:migrate
,出现错误,使我相信PG不支持JSON列类型:
PG::Error: ERROR: type "json" does not exist
但是我知道Postgres 9.2支持JSON(即http://www.postgresql.org/docs/devel/static/datatype-json.html)。
有趣的是,当我检查与“ psql”一起使用的PG的版本时,它显示9.0.4。而当我使用“ postgres”时,它显示为9.2.1。因此,我不确定自己使用的是哪个版本以及如何来回切换。
psql --version
psql (PostgreSQL) 9.0.4
postgres --version
postgres (PostgreSQL) 9.2.1
有谁想到我为什么会收到Postgres错误?
好的,结果是我曾经通过自制软件安装了postgres,并在不同的时间使用Postgres.app进行了安装。我通过检查'psql'和'postgres'的版本开始意识到这一点,并注意到了两者之间的区别。
psql --version
psql (PostgreSQL) 9.0.4
postgres --version
postgres (PostgreSQL) 9.2.4
我在此处使用其文档卸载了Postgres.app ,然后使用自制软件确保我使用的是最新版本的postgres。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句