# Migrations and Time datatype. Bug?

**URL:** <https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966>\
**Category:** Rails\
**Created:** [January 21, 2006, 7:19pm UTC](https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966 "2006-01-21T19:19:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@Garz](https://www.ruby-forum.com/u/Garz)\
**Post date:** [January 21, 2006, 7:19pm UTC](https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966/1 "2006-01-21T19:19:42Z")

</div>

I’ve defined a table with these columns  
t.column “some\_date”, :date, :null =\> false  
t.column “some\_time”, :time, :null =\> false

The result in schema.rb is  
t.column “some\_date”, :date, :null =\> false  
t.column “some\_time”, :time, :default =\> Sat Jan 01 00:00:00 GMT  
Standard Time 2000, :null =\> false

The time column generates a default I didn’t ask for. The default value  
given is not quoted and fails.

---

<div class="post-metadata">

**Author:** ![Garz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@Garz](https://www.ruby-forum.com/u/Garz)\
**Post date:** [January 21, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966/2 "2006-01-21T19:42:43Z")

</div>

This problem prevented me from using migrations.

[http://dev.rubyonrails.org/ticket/3232](http://dev.rubyonrails.org/ticket/3232)

Since the app I’m writing is Rails only, I decided  
to drop the default on the column, let Rails handle  
it, and learn about migrations.

Migrations rock. 🙂

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![Garz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@Garz](https://www.ruby-forum.com/u/Garz)\
**Post date:** [January 27, 2006, 12:45am UTC](https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966/3 "2006-01-27T00:45:35Z")

</div>

Is there any plans on fixing this bug? I have a rails application that  
will be using data in a lagacy db, and adding new tables. I would like  
to  
use migration to deal with the schema changes from the lagacy schema.  
My  
problem is that this bug makes migrations totally useless for this  
project.

---

<div class="post-metadata">

**Author:** ![Garz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@Garz](https://www.ruby-forum.com/u/Garz)\
**Post date:** [January 27, 2006, 10:18am UTC](https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966/4 "2006-01-27T10:18:32Z")

</div>

Hi Ken

I don’t know the status of this bug, but afaik you could still use  
direct  
sql calls from migrations as a workaround (never done that though, just  
a  
hint!).

cheers

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

---

<div class="post-metadata">

**Author:** ![Garz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@Garz](https://www.ruby-forum.com/u/Garz)\
**Post date:** [January 27, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/migrations-and-time-datatype-bug/52966/5 "2006-01-27T16:26:44Z")

</div>

The problem is with the schema.rb file. When it pulls the schema from  
the  
database, it writes seriously broken ruby code to the schema.rb file  
causing everything to break.
