我已将我的应用程序推送到 Heroku,现在正在尝试运行“$ heroku rake db:migrate”。我收到此错误:
PGError: 错误:关系“inventories”不存在 : 选择“库存”。*来自“库存”
在我的本地机器上一切正常。本地正在使用 SQLite 3。此外,该应用程序的先前版本运行良好——先前版本确实包含库存模型。现在,我已经(几乎)阅读了 stackoverflow 和网络上关于此问题的所有帖子,但我仍然找不到解决方法。有人对让它工作有任何建议吗?
ruby 1.9.2 返回 3
更新.. 以下是创建库存表的迁移源:
class CreateInventories < ActiveRecord::Migration
def self.up
create_table :inventories do |t|
t.decimal :initial_amount, :precision => 10, :scale => 2
t.decimal :remaining_amount, :precision => 10, :scale => 2
t.string :unit
t.decimal :cost, :precision => 10, :scale => 2
t.integer :type_id
t.integer :brand_id
t.integer :blend_id
t.integer :user_id
t.boolean :in
t.timestamps
end
end
def self.down
drop_table :inventories
end
end
最佳答案
您是否在迁移中使用了库存模型?也许您在迁移过程中遇到了错误,例如您在迁移本地数据库后编辑了迁移文件?
无论如何,运行 rake --trace db:migrate
应该会向您显示整个错误消息以及堆栈跟踪 - 您会发现有问题的代码行。
更新:
在您的堆栈跟踪中(链接在评论中)有一条可疑行:
...0-d4e1268c8981/mnt/config/environment.rb:5
有什么代码?
关于ruby-on-rails - Ruby On Rails Heroku 数据库 :migrate Aborted!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4256926/