PG错误尝试将rails db推送到heroku

时间:2012-05-12 23:52:44

标签: mysql ruby-on-rails postgresql heroku

我正在尝试将我的rails db推送到heroku使用:heroku run rake db:migrate并收到以下错误:

=  ChangeDateFormatInMyTable: migrating ======================================
-- change_column(:users, :date_of_birth, :datetime)
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  column "date_of_birth" cannot be cast to type "pg_catalog.timestamp"
: ALTER TABLE "users" ALTER COLUMN "date_of_birth" TYPE timestamp

2 个答案:

答案 0 :(得分:2)

尝试使用heroku run rake db:reset

通常使用Heroku和我的PG数据库,当我大量改变时,我必须进行重置。

答案 1 :(得分:1)

是“Heroku run rake db:reset”绝对有效。我一直有类似的问题

RemoveGirthFromProfile: migrating =========================================
-- remove_column(:profiles, :girth)
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  column "girth" of relation "profiles" does not exist
: ALTER TABLE "profiles" DROP "girth"

但是当我重置数据库时,它解决了我在heroku上的应用程序错误