Rails 3,迁移在本地工作,在Heroku中不起作用?

时间:2011-01-12 15:43:52

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

我最近发布了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)

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

这是我在SO上找到的工作!

How do I change column type in Heroku?

答案 1 :(得分:0)

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

我做了很多次,就像一个魅力。