# How can I define a column of type char instead of varchar

**URL:** <https://www.ruby-forum.com/t/how-can-i-define-a-column-of-type-char-instead-of-varchar/68187>\
**Category:** Rails\
**Created:** [September 10, 2006, 4:59am UTC](https://www.ruby-forum.com/t/how-can-i-define-a-column-of-type-char-instead-of-varchar/68187 "2006-09-10T04:59:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cafebabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b2d939/32.png) [@cafebabe](https://www.ruby-forum.com/u/cafebabe)\
**Post date:** [September 10, 2006, 4:59am UTC](https://www.ruby-forum.com/t/how-can-i-define-a-column-of-type-char-instead-of-varchar/68187/1 "2006-09-10T04:59:52Z")

</div>

I tried this in my migration:

t.column :password\_hash, :char, :limit=\>40, :null=\>false

but it generate a column of type ‘char(1)’, it seems that  
:limit does not take effect. So how can I define a column  
of type ‘char(40)’, thanks:)

---

<div class="post-metadata">

**Author:** ![cafebabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b2d939/32.png) [@cafebabe](https://www.ruby-forum.com/u/cafebabe)\
**Post date:** [September 10, 2006, 5:25am UTC](https://www.ruby-forum.com/t/how-can-i-define-a-column-of-type-char-instead-of-varchar/68187/2 "2006-09-10T05:25:06Z")

</div>

Ok, it seems the following works…  
t.column :password\_hash, ‘char(40)’, :null=\>false
