# Migrations bug with Rails 1.0, PostgreSQL 8.1?

**URL:** <https://www.ruby-forum.com/t/migrations-bug-with-rails-1-0-postgresql-8-1/50326>\
**Category:** Rails\
**Created:** [December 15, 2005, 8:34am UTC](https://www.ruby-forum.com/t/migrations-bug-with-rails-1-0-postgresql-8-1/50326 "2005-12-15T08:34:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [December 15, 2005, 8:34am UTC](https://www.ruby-forum.com/t/migrations-bug-with-rails-1-0-postgresql-8-1/50326/1 "2005-12-15T08:34:40Z")

</div>

Filed a ticket for bogus Ruby produced via:

rake db\_schema\_dump

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

I’d appreciate it if someone could verify against  
PostgreSQL 8.0.x

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [December 15, 2005, 10:38am UTC](https://www.ruby-forum.com/t/migrations-bug-with-rails-1-0-postgresql-8-1/50326/2 "2005-12-15T10:38:01Z")

</div>

What does this have to do with:

rake db\_schema\_dump

producing non-functional Ruby code that breaks tests  
and doesn’t correctly instantiate the database?

I find it rather hard to believe that broken code  
generation is expected behavior, or that the basis  
for the new DB migrations functionality is supposed  
to misassign default column value settings?

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [December 15, 2005, 9:52am UTC](https://www.ruby-forum.com/t/migrations-bug-with-rails-1-0-postgresql-8-1/50326/3 "2005-12-15T09:52:52Z")

</div>

On 14-dec-2005, at 22:06, Tom M. wrote:

> Filed a ticket for bogus Ruby produced via:
> 
> rake db\_schema\_dump
> 
> [http://dev.rubyonrails.org/ticket/3232](http://dev.rubyonrails.org/ticket/3232)

This is expected behavior.

If you want to set default values, the Rails way is to use a filter:

class Model \< ActiveRecord::Base

protected  
before\_create :set\_default\_values

def.set\_default\_value  
self.updated\_at = Time.now  
end  
end

However, in the case of updated\_at/on created\_at/on, Rails will  
automagically populate those if present.

–  
Regards, Charles.

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [December 15, 2005, 7:19pm UTC](https://www.ruby-forum.com/t/migrations-bug-with-rails-1-0-postgresql-8-1/50326/4 "2005-12-15T19:19:17Z")

</div>

On 15-dec-2005, at 10:35, Tom M. wrote:

> What does this have to do with:
> 
> rake db\_schema\_dump

Right. I missed that.

–  
Regards, Charles.
