Rails 3, migration works locally, doesn't work in Heroku?

I recently posted this question

which worked locally with the answer that I selected correctly, here is the migration that 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 got 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?

+3
source share
2 answers

Here is the work I found on SO!

How to change column type in Heroku?

+3
source

I would move back, delete the field, create a new field.

I have done this many times, worked like a charm.

0
source

Source: https://habr.com/ru/post/1784992/


All Articles