我从与我合作的人那里分叉了一个回购程序,我只是想让我的开发环境启动并运行。其中一个迁移具有json属性,我们在开发和生产中都使用Postgres:
class CreateExams < ActiveRecord::Migration
def change
create_table :exams do |t|
t.belongs_to :user
t.json :exam
t.timestamps
end
end
enddatabase.yml
development:
adapter: postgresql
database: examgen_development
host: localhost当我运行rake db:migrate时,我会得到一个错误,这会使我相信PG不支持JSON列类型:
PG::Error: ERROR: type "json" does not exist但我知道Postgres9.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有人想过我为什么会犯这样的错误吗?
发布于 2013-07-28 17:17:12
好的,原来我曾经通过自制的方式安装了postgres,并且在不同的时间也安装了Postgres.app。通过检查“psql”和“postgres”的版本,我开始意识到这一点,并注意到了两者之间的区别。
psql --version
psql (PostgreSQL) 9.0.4
postgres --version
postgres (PostgreSQL) 9.2.4我使用他们的文档Postgres.app卸载了here,然后使用了自制软件,确保了我使用的是最新版本的postgres。
https://stackoverflow.com/questions/17889885
复制相似问题