【问题标题】:Heroku rake db:migrate abortedHeroku rake db:迁移中止
【发布时间】:2012-09-08 05:26:04
【问题描述】:

我有一个在开发中运行良好的应用程序,但是当我将它推送到 heroku 并尝试运行“heroku run rake db:migrate”时,rake 中止并显示以下消息:

rake aborted!
PG::Error: ERROR:  relation "submissions" does not exist
LINE 4:              WHERE a.attrelid = '"submissions"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"submissions"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

我不确定从哪里开始测试。我在我的架构中找不到问题。 rake db:setup 也不起作用。这是我的架构:

ActiveRecord::Schema.define(:version => 20120913202908) do

  create_table "active_admin_comments", :force => true do |t|
    t.string   "resource_id",   :null => false
    t.string   "resource_type", :null => false
    t.integer  "author_id"
    t.string   "author_type"
    t.text     "body"
    t.datetime "created_at",    :null => false
    t.datetime "updated_at",    :null => false
    t.string   "namespace"
  end

  add_index "active_admin_comments", ["author_type", "author_id"], :name => "index_active_admin_comments_on_author_type_and_author_id"
  add_index "active_admin_comments", ["namespace"], :name => "index_active_admin_comments_on_namespace"
  add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id"

  create_table "admin_users", :force => true do |t|
    t.string   "email",                  :default => "", :null => false
    t.string   "encrypted_password",     :default => "", :null => false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          :default => 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at",                             :null => false
    t.datetime "updated_at",                             :null => false
  end

  add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true
  add_index "admin_users", ["reset_password_token"], :name => "index_admin_users_on_reset_password_token", :unique => true

  create_table "categories", :force => true do |t|
    t.string   "name"
    t.text     "description"
    t.datetime "created_at",  :null => false
    t.datetime "updated_at",  :null => false
    t.integer  "festival_id"
  end

  create_table "categories_users", :id => false, :force => true do |t|
    t.integer "category_id", :null => false
    t.integer "user_id",     :null => false
  end

  create_table "festivals", :force => true do |t|
    t.date     "opening_date"
    t.date     "closing_date"
    t.string   "title"
    t.string   "slogan"
    t.string   "tag"
    t.datetime "submission_start_date"
    t.datetime "submission_end_date"
    t.boolean  "published"
    t.datetime "created_at",            :null => false
    t.datetime "updated_at",            :null => false
  end

  create_table "links", :force => true do |t|
    t.string   "name"
    t.string   "url"
    t.string   "kind"
    t.integer  "submission_id"
    t.datetime "created_at",    :null => false
    t.datetime "updated_at",    :null => false
  end

  create_table "performers", :force => true do |t|
    t.string   "name"
    t.string   "email"
    t.integer  "submission_id"
    t.datetime "created_at",    :null => false
    t.datetime "updated_at",    :null => false
  end

  create_table "submissions", :force => true do |t|
    t.string   "show_title"
    t.string   "group_name"
    t.string   "home_city"
    t.string   "home_theater"
    t.string   "country"
    t.text     "promotional_description"
    t.text     "additional_information"
    t.string   "contact_name"
    t.string   "contact_phone"
    t.string   "contact_email"
    t.boolean  "glbt_showcase"
    t.boolean  "diversity_showcase"
    t.integer  "user_id"
    t.integer  "category_id"
    t.datetime "created_at",              :null => false
    t.datetime "updated_at",              :null => false
  end

  create_table "users", :force => true do |t|
    t.string   "email",                  :default => "", :null => false
    t.string   "encrypted_password",     :default => "", :null => false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          :default => 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at",                             :null => false
    t.datetime "updated_at",                             :null => false
    t.string   "name"
    t.string   "confirmation_token"
    t.datetime "confirmed_at"
    t.datetime "confirmation_sent_at"
    t.string   "unconfirmed_email"
    t.boolean  "curator"
  end

  add_index "users", ["email"], :name => "index_users_on_email", :unique => true
  add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true

  create_table "venues", :force => true do |t|
    t.string   "name"
    t.string   "address1"
    t.string   "address2"
    t.string   "city"
    t.string   "state"
    t.string   "zip"
    t.string   "box_office_number"
    t.string   "website"
    t.string   "stage_name"
    t.text     "description"
    t.string   "contact_name"
    t.string   "contact_phone_number"
    t.string   "contact_email"
    t.datetime "created_at",           :null => false
    t.datetime "updated_at",           :null => false
  end

end

关于我应该在哪里寻找问题的任何建议?我应该搜索什么?

我看到了许多类似的问题,但似乎没有明确的答案来寻找什么。

更新: 这是我的 ActiveAdmin 初始化程序:

ActiveAdmin.setup do |config|
  config.site_title = "Cif4"
  config.authentication_method = :authenticate_admin_user!
  config.current_user_method = :current_admin_user
  config.logout_link_path = :destroy_admin_user_session_path
  config.batch_actions = true
end

【问题讨论】:

  • 初始化器中有什么?任何试图对模型做任何事情的东西?该错误告诉您,当某些东西试图使用您的 Submission 类时,您没有 submissions 表。我在类似情况下看到 ActiveAdmin 是罪魁祸首,但我不使用它,所以这只是猜测。
  • mu,为 Active Admin 添加了初始化程序。里面有什么可疑的东西吗?
  • 如果您暂时删除 ActiveAdmin 会发生什么?
  • 我会试一试的。注释掉初始化器会有效地删除它吗?

标签: ruby-on-rails heroku migration rake


【解决方案1】:

由于 Heroku 的定价和数据库大小的变化,最近很多人都发生了这种情况。

如果您的应用有超过 10,000 行并且您的计划不够高,则写入失败。

我们对此的回答是我们必须:

1) 选择一个允许 400,000 行,而不仅仅是 10,000 行的 higehr 计划

2) 将我们的应用重新指向新数据库。我没有参与,但显然这一步认为已经完成,但实际上并没有,所以如果有必要也可以搜索一下。

【讨论】:

    猜你喜欢
    • 2011-04-21
    • 2023-03-04
    • 2013-02-01
    • 2013-01-10
    • 1970-01-01
    • 2011-08-05
    • 1970-01-01
    • 2011-09-07
    相关资源
    最近更新 更多