0

我正在使用带有以下迁移的 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
4

1 回答 1

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).

参考这个

于 2012-12-05T12:56:40.233 回答