Ruby on rails 什么会导致此迁移挂起?

Ruby on rails 什么会导致此迁移挂起?,ruby-on-rails,Ruby On Rails,我正在尝试将一个旧的1.2.6 Rails应用程序升级到2.3.8,但在迁移方面遇到了一些障碍。也就是说,如果在迁移中有类似ModelName.create(:foo=>“bar”)的内容,则迁移不会完成。它不会碰到无限循环或任何东西。它只是拒绝完成迁移 下面是一些示例代码 这项工作: class CreateNewsArticles < ActiveRecord::Migration def self.up create_table :news_articles, :forc

我正在尝试将一个旧的1.2.6 Rails应用程序升级到2.3.8,但在迁移方面遇到了一些障碍。也就是说,如果在迁移中有类似ModelName.create(:foo=>“bar”)的内容,则迁移不会完成。它不会碰到无限循环或任何东西。它只是拒绝完成迁移

下面是一些示例代码

这项工作:

class CreateNewsArticles < ActiveRecord::Migration
  def self.up
    create_table :news_articles, :force => true do |t|
      t.string  "name"
      t.string  "image"
      t.text    "body"
      t.boolean "featured", :default => "0"
      t.integer "position"
      t.timestamps
    end
    # Section.create(:name => 'News Articles', :controller => 'news_articles', :description => 'Add, edit, and delete news articles.')
  end

  def self.down
    drop_table :news_articles
    Section.find_by_name('News Articles').destroy
  end
end
在注释完该部分后,创建

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateNewsArticles: migrating =============================================
-- create_table(:news_articles, {:force=>true})
   -> 0.0479s
==  CreateNewsArticles: migrated (0.0481s) ====================================

** Invoke db:schema:dump (first_time)
** Invoke environment 
** Execute db:schema:dump
我已经在另一台电脑上试过了,效果很好。相同版本的rake、相同版本的ruby和rails被冻结

rake——版本:
rake,版本0.8.7
,ruby-v:
ruby 1.8.6(2010-02-05 patchlevel 399)[i686-darwin10.3.0]
,rails-v:
rails 2.3.8


有人有什么想法吗?

显然,使用ruby 1.8.6-p399是罪魁祸首。切换到1.8.6-p369解决了这个问题

您还可以尝试在移植中定义条形骨骼剖面模型。

您可以从不同的原因看到相同的症状:如果正在运行,移植可能会挂起:

$ rails console --sandbox

在另一个过程中。退出控制台进程可以完成迁移。

我也遇到了同样的问题。。我发现有一个空闲事务阻止了对该表的进一步查询

运行:

查看数据库进程。您必须终止空闲进程:

heroku pg:kill 913 --force -a

(913是空闲进程的ID->根据您的需要更改它

是迁移找不到节模型的问题吗?它会在不抛出错误的情况下退出,这似乎很奇怪。我不确定,这只是我在迁移异常时尝试的一件事。如果模型包含有关较旧架构的信息,则特别有用。您是否愿意详细说明n为什么这解决了它?或者你在哪里找到了解决方案!这解决了我的问题-但是我的问题在它到达时间线之前就挂起了,与OP的问题相反。一旦控制台冻结,我就无法在控制台中退出进程-Ctrl+C没有任何效果。我必须关闭终端窗口以终止进程。一旦我退出了在另一个终端中的andbox控制台中,我的数据库最终被搞砸了-回滚/迁移不起作用,因为原始迁移已被终止,无法正常终止。我必须回滚到迁移,创建导致问题的表,然后才能向上迁移。
heroku pg:ps
heroku pg:kill 913 --force -a