Heroku db和本地db之间的区别

时间:2014-01-03 08:24:34

标签: ruby-on-rails postgresql heroku

我的Heroku数据库中有一些奇怪的行为。当我在本地的Rails应用程序中提交表单时,它会被存储好:

(0.2ms)  BEGIN
SQL (0.5ms)  INSERT INTO "gamerounds" ("created_at", "end_date", "number", "period_id", "processed", "start_date", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["created_at", Fri, 03 Jan 2014 09:18:26 CET +01:00], ["end_date", Wed, 02 Mar 2011 00:00:00 CET +01:00], ["number", 46], ["period_id", 3], ["processed", false], ["start_date", Sat, 02 Apr 2011 00:00:00 CEST +02:00], ["updated_at", Fri, 03 Jan 2014 09:18:26 CET +01:00]]
(0.3ms)  COMMIT

当我在Heroku应用程序(相同的代码,相同的数据库)上执行相同操作时,我收到此错误:

Started POST "/gamerounds" for 77.250.108.220 at 2014-01-03 08:15:05 +0000
ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "gamerounds" does not exist at character 13
INSERT INTO "gamerounds" ("created_at", "end_date", "number", "period_id", "processed", "start_date", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"):
app/controllers/clubs_frenzy/gamerounds_controller.rb:22:in `create'

当我在Heroku上创建一个带有select * from gamerounds;的Postgres数据表时,它只返回带有记录的表而没有问题。我恢复了Heroku上的本地数据库,所以它们完全一样。如果代码和数据库都相同,可能会出现什么问题?

1 个答案:

答案 0 :(得分:0)

尝试运行以下命令

heroku run rake db:reset
heroku run rake db:migrate
heroku restart