我正在关注RailsTutorial.org教程,第7.3节,并尝试使用rake将数据库迁移添加到现有数据库的密码列。看来正在发生的事情是,rails重新运行先前的迁移文件并尝试添加表Users(已存在),而不是最新的迁移文件并添加密码列。任何帮助,将不胜感激!Rails DB迁移错误,Rails重新运行以前的迁移?
这里是我跑生成迁移文件中的代码:
$ rails generate migration add_password_to_users encrypted_password:string
然后我跑耙分贝:迁移并得到了以下错误:
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "users" already exists: CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "email" varchar(255), "created_at" datetime, "updated_at" datetime)
似乎你做了一个以前的迁移创建用户表的副本。看看你的数据库/迁移文件夹 – apneadiving 2011-01-24 17:48:47
应该有两个迁移包含:create_table:users – apneadiving 2011-01-24 17:54:21