我正在尝试将hstore添加到我的应用程序中。但是我收到一个错误,告诉我hstore不存在。
PG::UndefinedObject: ERROR: type "hstore" does not exist
LINE 1: ALTER TABLE "people" ADD COLUMN "custom_fields" hstore
这是我的迁移:
class AddCustomFieldsToPeople < ActiveRecord::Migration
def up
add_column :people, :custom_fields, :hstore
end
def down
remove_column :people, :custom_fields
end
end
根据this SO answer我不必在每个模式上创建hstore扩展,只是将其添加到例如公共模式。
有什么我需要做的事情,添加postgres扩展以让hstore工作吗?
感谢任何帮助。 :)
答案 0 :(得分:1)
使用this和rake生成迁移:
class AddHstore < ActiveRecord::Migration
def up
enable_extension :hstore
end
def down
disable_extension :hstore
end
end
由于您已经有一个迁移暂挂,请使用rake db:migrate:up VERSION =