Rails DB移行を実行した後、mysqlにフィールドがありません
-
05-07-2019 - |
質問
iにはRailsの移行があります:
>> 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
&quot; t.int:sec_code&quot;に注意してください。ライン。正常に実行されているようです:
>> rake db:migrate(in /Users/aaronj1335/Sites/clarkbox)
== CreateCards: migrating ====================================================
-- create_table(:cards)
-> 0.4315s
== CreateCards: migrated (0.4317s) ===========================================
ただし、&quot; sec_code&quot;列は作成されません:
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列が作成されないのはなぜですか?エラーが発生するようです...
解決
t.intは、おそらくt.integerでなければなりません。それを試してください。
疑わしい場合、 dizzy には常に素晴らしい参照があります。
他のヒント
まあ、&quot; number&quot;も表示されません。フィールドは適切に作成されているため、タイプである必要があります(t.int:numberが欠落しています)
所属していません StackOverflow