# Timestamps in Migrations

**URL:** <https://www.ruby-forum.com/t/timestamps-in-migrations/135240>\
**Category:** Rails\
**Created:** [April 19, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/timestamps-in-migrations/135240 "2008-04-19T17:36:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miquel\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@Miquel\_O](https://www.ruby-forum.com/u/Miquel_O)\
**Post date:** [April 19, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/timestamps-in-migrations/135240/1 "2008-04-19T17:36:20Z")

</div>

Hi there again 🙂

I’m creating my mysql tables using migrations and I have noticed that  
the t.timestamps line creates two columns named ‘created\_at’ and  
‘updated\_at’ as datetime type but they allow null values.

How can I say to rails I want that these two columns are not null  
(:null=\>default doesn’t work).

Regards

–

Miquel (a.k.a. Ktalà a.k.a. Ton)  
Linux User #286784  
GPG Key : 4D91EF7F  
Debian GNU/Linux (Linux wolverine 2.6.23.1)

Welcome to the jungle, we got fun and games  
Guns n’ Roses

---

<div class="post-metadata">

**Author:** ![Miquel\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@Miquel\_O](https://www.ruby-forum.com/u/Miquel_O)\
**Post date:** [April 19, 2008, 6:45pm UTC](https://www.ruby-forum.com/t/timestamps-in-migrations/135240/2 "2008-04-19T18:45:54Z")

</div>

You can specify that a column allows NULL or not like this:  
:null =\> true  
:null =\> false

The docs for TaleDefinition#column should be useful. That’s the method  
that’s called when you use, e.g., add\_column in a migration.

[http://www.railsbrain.com/api/edge/doc/index.html?a=M001499&name=TableDefinition#column](http://www.railsbrain.com/api/edge/doc/index.html?a=M001499&name=TableDefinition#column)

Regards,  
Craig
