Ruby on rails Rails在初始迁移期间查找schema_migrations表中不存在的ID列

Ruby on rails Rails在初始迁移期间查找schema_migrations表中不存在的ID列,ruby-on-rails,ruby,rake,rails-postgresql,Ruby On Rails,Ruby,Rake,Rails Postgresql,在新数据库上运行迁移会导致以下错误 >> rake db:drop; rake db:create:all; rake db:migrate 1 activity-image-additions-!? == CreateSomething: migrating =====================

在新数据库上运行迁移会导致以下错误

>> rake db:drop; rake db:create:all; rake db:migrate
                                                                                           1 activity-image-additions-!?
==  CreateSomething: migrating ================================================
-- create_table(:somethings)
   -> 0.0042s
==  CreateSomething: migrated (0.0043s) =======================================

rake aborted!
An error has occurred, this and all later migrations canceled:

PG::UndefinedColumn: ERROR:  column "id" does not exist
LINE 1: ...O "schema_migrations" ("version") VALUES ($1) RETURNING "id"
                                                                   ^
: INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "id
生成的SQL查询不应包含返回“id”的
,因为schema\u migrations表没有id

如果在失败后尝试迁移数据库,则会成功:

>> rake db:migrate

==  CreateSomething: migrating ================================================
-- create_table(:somethings)
   -> 0.0041s
==  CreateSomething: migrated (0.0042s) =======================================
我目前正在OS X 10.8上运行PostgreSQL 9.2.4、Rails 4.0.0、pg gem 0.16.0

唯一的迁移:

class CreateSomething < ActiveRecord::Migration
  def change
    create_table :somethings do |t|
      t.integer :x
      t.integer :y
    end
  end
end
class-CreateSomething
注意:我曾在其他Rails项目中尝试过这种迁移,而且效果很好。还有点不对劲,但我不知道从哪里开始


堆栈跟踪可用。

在我的例子中,此问题是由属性\u normalizergem引起的。(见附件) 只有在第一次迁移之后,数据库完全为空时才会发生这种情况


使用1.2预发行版解决了这个问题。

当您设置一个新的数据库时,您不应该运行
rake db:migrate
。相反,您应该使用
rakedb:schema:load


迁移系统旨在更新模式。在新安装上,立即加载最新架构更快、更方便。

我刚刚使用SQLite和Postgres在本地运行了相同的精确迁移,没有任何问题。我在另一个Rails项目中也做了同样的事情,没有任何问题。还有点不对劲。。。但我不确定是什么。迁移系统使用
schema\u migrations
表跟踪已运行的迁移,它应该有一个
version varchar(255)not null
列。是否有可能从该异常中看到堆栈跟踪?以下是原因。我不确定为什么会追加返回“id”的
位…看起来我把
创建
设置混为一谈了。此外,这是DB特有的问题吗?我在使用sqlite时没有看到这个错误。谢谢分享。这让我很困惑。