尝试添加Hstore迁移会在架构中产生“StandardError”

时间:2018-02-02 13:45:12

标签: ruby-on-rails activerecord ruby-on-rails-5

我正在尝试将Hstore“Details”列添加到product表中,如下所示:

# 20180202133309_add_hstore_extension.rb
class AddHstoreExtension < ActiveRecord::Migration[5.1]
  def self.up
    enable_extension "hstore"
  end
  def self.down
    disable_extension "hstore"
  end
end

上面运行了迁移,然后是

下面的迁移
# 20180202133435_add_hstore_to_products.rb
class AddHstoreToProducts < ActiveRecord::Migration[5.1]
  def change
    add_column :products, :details, :hstore
    add_index :products, :details, using: :gin
  end
end

我认为可能有必要在列添加迁移之前运行enable_extension迁移,但无论哪种方式,它都会在我的架构中出现以下错误

# schema.rb
# Could not dump table "products" because of following StandardError
#   Unknown type 'hstore' for column 'details'

该表在我的应用程序中仍然可以正常工作,所以这是一个我可以忽略的错误吗?我不喜欢无法在我的架构中查看该表。

1 个答案:

答案 0 :(得分:1)

Lost my schema.rb! Can it be regenerated?

或者为了省时间,请尝试终端:

rake db:schema:dump