2014-02-17 30 views
0

當我生成新遷移並通過同時向上和向下進行檢查時,我會收到'rake中止!最後當我走下去的時候,儘管它運行着所有的遷徙。在遷移時沒有問題,一切都很順利。有人可以告訴我爲什麼會發生這種情況嗎?即使完全運行遷移後Rake也會中止

$ 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

目前還不清楚。請提供一些有用的信息。 – bprayudha

+0

這裏是代碼 – anmolagrawal

回答

0

使用

要向上遷移運行

rake db:migrate:up VERSION=version number of migration 

而對於向下運行遷移

rake db:migrate:down VERSION=version number of migration 
0

你 '調用createUsers' 遷移文件包含錯誤。請先觀察用戶創建文件。它可能具有一些依賴性,如您在創建遷移中添加特定用戶角色,但在用戶表之前未創建角色表。如果您將'CreateUsers'遷移文件粘貼到某處,然後在此處粘貼該鏈接,則很容易找出問題所在。

+0

我已經粘貼了上面的CreateUsers類。我沒有看到任何問題。你能找到任何東西嗎? – anmolagrawal

+0

請檢查遷移。 ':'和'users'之間是否有任何空格,如create_table:用戶 –

+0

。沒有錯 – anmolagrawal

相關問題