heroku迁移问题

时间:2013-04-06 15:34:54

标签: heroku migration

运行heroku后运行db:migrate,我收到此错误。 。这个应用程序在开发中运行良好。我也在这个网站上做了一些研究,尝试了几种解决方案,似乎没有用。有人帮我弄明白我该如何解决这个问题?

==  CreatePins: migrating =====================================================
-- create_table(:pins)
NOTICE:  CREATE TABLE will create implicit sequence "pins_id_seq1" for serial column "pins.id"
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  relation "pins" already exists
: CREATE TABLE "pins" ("id" serial primary key, "description" character varying(255), "created_at" timestamp N
OT NULL, "updated_at" timestamp NOT NULL) /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_re
cord/connection_adapters/postgresql_adapter.rb:650:in `exec'

1 个答案:

答案 0 :(得分:0)

所以这告诉你pins已经存在。可能是您有两个创建pins的迁移,或者您已经设法创建一个表而没有Rails知道/记住它正在运行迁移。我发现如果您使用heroku db:push将单个表推送到这个状态,在这种情况下pins推送到Heroku而不是schema_migrations的内容,那么当您尝试运行时表存在的迁移。

如果它是新的并且你没有引脚中的任何数据你可以使用psql,pgadmin工具等来删除引脚表,重新运行迁移并让Rails执行迁移并存储它已经完成的事实(它在schema_migrations表中存储迁移的标识)