# Unsigned column

**URL:** <https://www.ruby-forum.com/t/unsigned-column/91472>\
**Category:** Rails\
**Created:** [April 9, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/unsigned-column/91472 "2007-04-09T16:14:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Ammous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Julien\_Ammous](https://www.ruby-forum.com/u/Julien_Ammous)\
**Post date:** [April 9, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/unsigned-column/91472/1 "2007-04-09T16:14:31Z")

</div>

Hi,  
I can’t manage to get an unsigned int column with activerecord  
migration, I am using this definition:

create\_table :emails, :use\_big\_id =\> true do |t|  
t.column “destination”, :string, :limit =\> 60, :null =\> false  
t.column “object”, :string, :limit =\> 200, :null =\> false  
t.column “options”, :string, :null =\> false

t.column “created\_at”, :datetime, :null =\> false

# FK

t.column “user\_id”, :bigint, :unsigned =\> true, :null =\> false  
end

isn’t the “:unsigned =\> true” supposed to create an unsigned column ?

---

<div class="post-metadata">

**Author:** ![Julien\_Ammous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Julien\_Ammous](https://www.ruby-forum.com/u/Julien_Ammous)\
**Post date:** [April 9, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/unsigned-column/91472/2 "2007-04-09T17:06:05Z")

</div>

If you’re absolutely sure you’re going to be using a DBMS that supports  
it,  
you can use

```
  t.column :my_unsigned_int, :"int unsigned"

```

to get what you want. If you need something other than the default limit  
on  
int there…

```
  t.column :my_unsigned_int, :"int(24) unsigned"

```

should do the job.

RSL

---

<div class="post-metadata">

**Author:** ![Julien\_Ammous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Julien\_Ammous](https://www.ruby-forum.com/u/Julien_Ammous)\
**Post date:** [April 10, 2007, 1:39pm UTC](https://www.ruby-forum.com/t/unsigned-column/91472/3 "2007-04-10T13:39:22Z")

</div>

Thanks for your answer, I will try that.  
I am using mysql and it won’t change on this project.

---

<div class="post-metadata">

**Author:** ![Julien\_Ammous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Julien\_Ammous](https://www.ruby-forum.com/u/Julien_Ammous)\
**Post date:** [July 1, 2008, 8:05pm UTC](https://www.ruby-forum.com/t/unsigned-column/91472/4 "2008-07-01T20:05:01Z")

</div>

For me it makes total sense to use “unsigned” in primary/foreign keys  
definitions whenever the DB supports it.

There is even a patch for this:  
[http://dev.rubyonrails.org/ticket/5219](http://dev.rubyonrails.org/ticket/5219)

Discussion about this topic:  
[http://www.ruby-forum.com/topic/155218](http://www.ruby-forum.com/topic/155218)
