2009-11-26 36 views
0

我有一個Rails遷移:MySQL的運行後失蹤場軌數據庫遷移

>> cat db/migrate/20091126031039_create_cards.rb 
class CreateCards < ActiveRecord::Migration 
    def self.up 
    create_table :cards do |t| 
     t.string :number_hash 
     t.int :number 
     t.string :name 
     t.string :type 
     t.string :expiration 
     t.int :sec_code 

     t.timestamps 
    end 
    end 

    def self.down 
    drop_table :cards 
    end 
end 

通知 「t.int:SEC_CODE」 行。它似乎成功地執行:

>> rake db:migrate(in /Users/aaronj1335/Sites/clarkbox) 
== CreateCards: migrating ==================================================== 
-- create_table(:cards) 
    -> 0.4315s 
== CreateCards: migrated (0.4317s) =========================================== 

但沒有創建 「SEC_CODE」 列:

mysql> describe cards; 
+-------------+--------------+------+-----+---------+----------------+ 
| Field  | Type   | Null | Key | Default | Extra   | 
+-------------+--------------+------+-----+---------+----------------+ 
| id   | int(11)  | NO | PRI | NULL | auto_increment | 
| number_hash | varchar(255) | YES |  | NULL |    | 
| name  | varchar(255) | YES |  | NULL |    | 
| type  | varchar(255) | YES |  | NULL |    | 
| expiration | varchar(255) | YES |  | NULL |    | 
| created_at | datetime  | YES |  | NULL |    | 
| updated_at | datetime  | YES |  | NULL |    | 
+-------------+--------------+------+-----+---------+----------------+ 
7 rows in set (0.00 sec) 

爲什麼不SEC_CODE列創建?好像我應該得到一個錯誤...

回答

2

t.int應該可能是t.integer。給那一槍。

如有疑問,dizzy總是有一些很好的參考。

+0

堅果,這是一個愚蠢的錯誤,謝謝。 – aaronstacy 2009-11-26 03:35:06

0

嗯,我還沒有看到被正確創建的「數字」域中,因此它必須是類型(t.int:號丟失)