Forum: Ruby on Rails unsigned column

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Julien Ammous (Guest)
on 2007-04-09 18:14
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

isn't the ":unsigned => true" supposed to create an unsigned column ?
Russell N. (Guest)
on 2007-04-09 19:06
(Received via mailing list)
If you're absolutely sure you're going to be using a DBMS that supports
you can use

      t.column :my_unsigned_int, :"int unsigned"

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

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

should do the job.

Julien Ammous (Guest)
on 2007-04-10 15:39
Thanks for your answer, I will try that.
I am using mysql and it won't change on this project.
Geraldo (Guest)
on 2008-07-01 22:05
(Received via mailing list)
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:

Discussion about this topic:
This topic is locked and can not be replied to.