使用Postgres和Monetize在Heroku上的迁移错误

时间:2019-05-08 18:10:13

标签: ruby postgresql heroku

我有一个RoR 5.1应用,正在尝试将其部署到Heroku。

在我的gem文件中,将宝石“ pg”指定为生产用。我还包括宝石“ money-rails”。在我的数据库/迁移文件中,我有几行内容可以创建“获利”类型的字段,据我了解,应该通过添加“ money-rails” gem来处理。

部署应用程序时,我没有遇到任何问题,但是当我迁移数据库以创建表时,出现以下错误:

StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedObject: ERROR:  type "monetize" does not exist
: ALTER TABLE "plans" ALTER COLUMN "price" TYPE monetize
(followed by additional error lines)

关于如何解决此问题的任何想法?我需要添加宝石吗?在Heroku上是否需要更新/安装某些东西?我不确定是否有办法忽略执行这些特定的迁移,因为这些迁移对于代码库而言不是必需的。

我可以编写一个迁移操作来删除表,但这只会在它尝试创建表之后发生,所以不确定解决方法是什么。

根据评论,这是创建了相关表格之一的迁移:计划

class CreatePlans < ActiveRecord::Migration[5.1]
  def change
    create_table :plans do |t|
      t.string :payment_gateway_plan_identifier
      t.string :name
      t.float :price
      t.integer :interval
      t.integer :interval_count
      t.integer :status
      t.text :description

      t.timestamps
    end
  end
end

然后是我为实现“获利”所做的更改:

class ChangePriceToMonetizeInPlans < ActiveRecord::Migration[5.1]
  def change
    change_column :plans, :price, :monetize
  end
end

显然,根据评论,获利也不是受支持的PG类型。但是,由于我已经创建了迁移(我在开发中使用了SQL lite 3),所以我不确定如何退回并删除它,因为我认为迁移是有序的。抱歉,对我来说,这种迁移的东西(和一般的导轨)仍然是新的。

0 个答案:

没有答案
相关问题