将应用程序迁移到heroku时出错

时间:2016-08-18 09:38:32

标签: ruby-on-rails heroku

我正在尝试将我的应用程序迁移到heroku并且出现此错误,导致我的迁移回滚。谁能告诉我为什么date_time出错?

remembrance:~/rails_project/alpha-blog (master) $ heroku run rake db:migrate
Running rake db:migrate on ⬢ alpha-blog-javier... up, run.4829
  ActiveRecord::SchemaMigration Load (1.9ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Migrating to AddDescriptionToArticles (20160816052220)
   (1.7ms)  BEGIN
== 20160816052220 AddDescriptionToArticles: migrating =========================
-- add_column(:articles, :description, :text)
   (2.1ms)  ALTER TABLE "articles" ADD "description" text
   -> 0.0024s
-- add_column(:articles, :created_at, :date_time)
   (4.1ms)  ALTER TABLE "articles" ADD "created_at" date_time
   (1.7ms)  ROLLBACK
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedObject: ERROR:  type "date_time" does not exist
LINE 1: ALTER TABLE "articles" ADD "created_at" date_time

enter image description here

2 个答案:

答案 0 :(得分:1)

应该{​​{1}}而不是datetime。阅读documentation

答案 1 :(得分:1)

更改此行

add_column(:articles, :created_at, :date_time)

迁移到

add_column(:articles, :created_at, :datetime)