簡體   English   中英

為什么在沒有時間戳的情況下創建created_at / updated_at?

[英]Why do created_at/updated_at get created when migration does not have timestamps?

我正在使用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

請刪除表格,然后再次檢查,因為

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

引用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM