Ruby On Rails Heroku db:migrate Aborted! [英] Ruby On Rails Heroku db:migrate Aborted!

查看:102
本文介绍了Ruby On Rails Heroku db:migrate Aborted!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将我的应用推送到Heroku,现在正在尝试运行'$ heroku rake db:migrate'。我得到这个错误:

PGError:ERROR:关系库存不存在
:SELECT库存* FROM库存



在我的本地机器上,一切都很好。本地使用的是SQLite 3.此外,以前版本的应用程序工作得很好 - 以前的版本确实包含了库存模型。现在,我已经阅读(几乎)每一篇关于这个问题的帖子,并且在网络上,但我仍然无法找到解决方法。有没有人有任何建议让这个工作?



Ruby 1.9.2
ROR 3



UPDATE ..
这是创建库存表的迁移源:

  class CreateInventories< ActiveRecord :: Migration 
def self.up
create_table:inventory | 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
结束
结束

def self.down
drop_table:库存
结束
结束


解决方案

解决方案:我终于找出问题所在。

  def self.search(id)
@inventory = Inventory.where在我的用户模型中使用了此方法:

(:primary_user [id])
@cups = Cup.where(:user_id [id])

@inventory + @cups
end

由于某些原因,导致错误。我将它更新为使用 @ user.inventories @ user.cups 来代替。谢谢大家。


I've pushed my app to Heroku and now am trying to run '$ heroku rake db:migrate'. I get this error:

PGError: ERROR: relation "inventories" does not exist : SELECT "inventories".* FROM "inventories"

On my local machine everything works great. The local is using SQLite 3. Also, previous versions of the app worked just fine -- the previous versions did include the inventories model. Now, I've read ( almost ) every post on stackoverflow and on the web about this issue, but I still cannot find a way around it. Does anybody have any advice on getting this to work?

Ruby 1.9.2 ROR 3

UPDATE.. Here is the source to the migration that creates the inventories table:

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

解决方案

SOLUTION: I finally figured out the issue. I had this method in my user model:

def self.search( id )
  @inventory = Inventory.where(:primary_user [id])
  @cups = Cup.where(:user_id [id])

  @inventory + @cups
end

For some reason, that caused errors. I updated it to use @user.inventories and @user.cups instead. Thanks everybody.

这篇关于Ruby On Rails Heroku db:migrate Aborted!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆