【问题标题】:Rails 3, migration works locally, does not work in Heroku?Rails 3,迁移在本地工作,在 Heroku 中不起作用?
【发布时间】:2011-06-07 22:17:09
【问题描述】:

我最近发了this question

在本地使用我选择正确的答案,这是我基本上使用的迁移:

class ChangeColumnToUsers < ActiveRecord::Migration
  def self.up
    change_column :users, :created_at, :datetime

  end

  def self.down
    change_column :users, :created_at, :string
  end
end

运行 heroku rake db:migrate 后,我收到此错误:

rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR:  column "deadline" cannot be cast to type "date"
: ALTER TABLE "tasks" ALTER COLUMN "deadline" TYPE date

(See full trace by running task with --trace)
(in /disk1/home/slugs/18c5c920-2e22-40f5-8d6a-b20a0fc5d7ba/mnt)
==  ChangeColumnToUsers: migrating ============================================
-- change_column(:users, :created_at, :datetime)

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 heroku


    【解决方案1】:

    这是我在 SO 上找到的解决方法!

    How do I change column type in Heroku?

    【讨论】:

      【解决方案2】:

      我会迁移回来,删除字段,创建新字段。

      我这样做了很多次,工作就像一个魅力。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-08-16
        • 1970-01-01
        • 2011-01-07
        • 1970-01-01
        • 2021-05-10
        • 2012-07-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多