created_at和updated_at列来自哪里? [英] Where do the created_at and updated_at columns come from?
本文介绍了created_at和updated_at列来自哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由rails应用程序创建的数据库中的所有表似乎都有created_at和updated_at列。什么创造这些?
All the tables in the database created by a rails application seem to have created_at and updated_at columns. What creates these? Are they optional, or does something internal rely on them?
推荐答案
当您运行ActiveRecord迁移时,它们是默认创建的模型。 ActiveRecord会在您分别创建或更新模型实例(从而基础数据库表行)时自动填充/更新它们。
They are created by default when you run the ActiveRecord migration for a model. ActiveRecord automatically populates/updates them when you create or update a model instance (and thus the underlying database table row) respectively.
您可以删除 t.timestamps
行。
- Ruby on Rails Guides: Migrations
这篇关于created_at和updated_at列来自哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文