当我生成一个新的迁移,并通过上下两个检查时,我得到'rake aborted!'最后,当我走下去,虽然它运行所有的迁移。在迁移过程中没有问题,一切顺利。谁能告诉我为什么会这样?
$ rake db:migrate VERSION= 20140217090240
== CreateSections: reverting =================================================
-- drop_table(:sections) -> 0.0050s
== CreateSections: reverted (0.0060s) ========================================
== CreatePages: reverting ====================================================
-- drop_table(:pages) -> 0.0030s
== CreatePages: reverted (0.0040s) ===========================================
== CreateSubjects: reverting =================================================
-- drop_table(:subjects) -> 0.0030s
== CreateSubjects: reverted (0.0230s) ========================================
== AlterUsers: reverting =====================================================
-- remove_index("admin_users", "username") -> 0.0180s
-- rename_column("admin_users", "hashed_password", "password") -> 0.0160s
-- change_column("admin_users", "email", :string, {:default=>"", :null=>false}) -> 0.0110s
-- remove_column("admin_users", "username") -> 0.0110s
-- rename_table("admin_users", "users") -> 0.0030s
== AlterUsers: reverted (0.0680s) ============================================
== CreateUsers: reverting ====================================================
-- drop_table(:users) -> 0.0040s
== CreateUsers: reverted (0.0040s) ===========================================
rake aborted! Don't know how to build task '20140217090240'
(See full trace by running task with --trace)
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string "first_name", :limit => 25
t.string "last_name", :limit => 50
t.string "email", :default => "", :null => false
t.string "password", :limit => 40
t.timestamps
end
end
def down
drop_table :users
end
end
答案 0 :(得分:0)
使用
完成迁移运行
rake db:migrate:up VERSION=version number of migration
关于迁移运行
rake db:migrate:down VERSION=version number of migration
答案 1 :(得分:0)
您的“CreateUsers”迁移文件包含错误。请先观察用户创建文件。它可能具有某些依赖性,例如您在创建迁移中添加某些用户角色但在用户表之前未创建角色表。如果您在某处粘贴“CreateUsers”迁移文件,然后在此处粘贴链接,则很容易找到问题。