2013-04-06 165 views
-1

我运行heroku运行db:migrate后,出现此错误。 。该应用程序在开发中运行良好。我也在本网站上做了一些研究,并尝试了几种解决方案,似乎无法正常工作。有人帮我弄清楚我该如何解决这个问题?heroku迁移问题

== 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' 

回答

0

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

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