Forum: Ruby on Rails unsigned column

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fd72d5bcc556c96fc1585c91228d75c1?d=identicon&s=25 Julien Ammous (Guest)
on 2007-04-09 16:14
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 ?
5030981121b21bed8aee074f68bd5074?d=identicon&s=25 Russell Norris (Guest)
on 2007-04-09 17:06
(Received via mailing list)
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
Fd72d5bcc556c96fc1585c91228d75c1?d=identicon&s=25 Julien Ammous (Guest)
on 2007-04-10 13:39
Thanks for your answer, I will try that.
I am using mysql and it won't change on this project.
9492542daff28a5708178ce73274ef70?d=identicon&s=25 Geraldo (Guest)
on 2008-07-01 20: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:
   http://dev.rubyonrails.org/ticket/5219

Discussion about this topic:
  http://www.ruby-forum.com/topic/155218
This topic is locked and can not be replied to.