开发者

Rails 3, migration works locally, does not work in Heroku?

I recently posted this question

which worked locally with the answer I selected as correct, here is the migration I used essentially:

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

After running heroku rake db:migrate, I received this error:

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)

Any ideas?


Here is the work around I found on SO!

How do I change column type in Heroku?


I would migrate back, delete the field, create the new field.

I did this plenty of times, worked like a charm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜