我使用rails 3.2进行以下迁移,并且created_at / updated_at都生成了。我的印象是添加t.timestamps是导致这些列生成的原因。
class CreateContactsCountries < ActiveRecord::Migration
def change
create_table :contacts_countries do |t|
t.string :name, :official_name, :null => false
t.string :alpha_2_code, :null => false, :limit => 2
t.string :alpha_3_code, :null => false, :limit => 3
end
add_index :contacts_countries, :alpha_2_code
end
end
答案 0 :(得分:0)
请删除该表并再次检查
By default, the generated migration will include t.timestamps (which creates
the updated_at and created_at columns that are automatically populated
by Active Record).
参考this