# How can I set default value for each column in a Database?

**URL:** <https://www.ruby-forum.com/t/how-can-i-set-default-value-for-each-column-in-a-database/153933>\
**Category:** Ruby\
**Created:** [November 23, 2008, 11:28am UTC](https://www.ruby-forum.com/t/how-can-i-set-default-value-for-each-column-in-a-database/153933 "2008-11-23T11:28:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [November 23, 2008, 11:28am UTC](https://www.ruby-forum.com/t/how-can-i-set-default-value-for-each-column-in-a-database/153933/1 "2008-11-23T11:28:49Z")

</div>

I created a database in my rails project and want to set default value  
for each column. I have read the self.up method of the file  
db\migrate\20081123094926\_create\_bay\_infos.rb and thought that this is  
where I need to modify. But I don’t know how to do this.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [November 23, 2008, 11:53am UTC](https://www.ruby-forum.com/t/how-can-i-set-default-value-for-each-column-in-a-database/153933/2 "2008-11-23T11:53:07Z")

</div>

Zhao Yi wrote:

> I created a database in my rails project and want to set default value  
> for each column. I have read the self.up method of the file  
> db\migrate\20081123094926\_create\_bay\_infos.rb and thought that this is  
> where I need to modify. But I don’t know how to do this.

[http://ar.rubyonrails.com/](http://ar.rubyonrails.com/)

Scroll down to “migrations”, click “learn more”

Search for :default to see some examples

Note that Rails questions are best asked on a Rails mailing list or  
group. This list is focussed on the Ruby programming language, not Rails  
(which is an application/framework written _in_ Ruby)

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [November 23, 2008, 12:06pm UTC](https://www.ruby-forum.com/t/how-can-i-set-default-value-for-each-column-in-a-database/153933/3 "2008-11-23T12:06:14Z")

</div>

Brian C. wrote:

> Zhao Yi wrote:
> 
> > I created a database in my rails project and want to set default value  
> > for each column. I have read the self.up method of the file  
> > db\migrate\20081123094926\_create\_bay\_infos.rb and thought that this is  
> > where I need to modify. But I don’t know how to do this.
> 
> [http://ar.rubyonrails.com/](http://ar.rubyonrails.com/)
> 
> Scroll down to “migrations”, click “learn more”
> 
> Search for :default to see some examples
> 
> Note that Rails questions are best asked on a Rails mailing list or  
> group. This list is focussed on the Ruby programming language, not Rails  
> (which is an application/framework written _in_ Ruby)

Oh sorry for posting to a wrong forum. Thanks.
