i noticed that rails create signed int(11) for id fields (i''m using mysql, i don''t know if it acts like this with different databases). i think that unsigned is better for primary keys (and foreign keys). Is there an easy way to indicate that in a migration? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
Quoting eugenio <eugenio.modesti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> i noticed that rails create signed int(11) for id fields (i''m using > mysql, i don''t know if it acts like this with different databases). > i think that unsigned is better for primary keys (and foreign keys). > Is there an easy way to indicate that in a migration? >This comes up occassionally. The current answer is no. My quess is that not all supported databases support unsigned. There is a way to create an unsigned int column (that I''ve forgotten) but it isn''t carried over to the test database. So you can used unsigned ints, just cant'' test the upper half of the values. Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
On Nov 22, 11:44 am, eugenio <eugenio.mode...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i noticed that rails create signed int(11) for id fields (i''m using > mysql, i don''t know if it acts like this with different databases). > i think that unsigned is better for primary keys (and foreign keys). > Is there an easy way to indicate that in a migration?There''s not a way to do so, as far as I know. Somewhat offtopic, why do you believe that unsigned is preferable? Yes, it has twice as much range, but if your DB has 2 billion objects in it and needs more - you''ve likely got other problems... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
you are right. but because they''re use the same memory i thought it would be correct to let the application to use all of them if needed. i think it''s just a mysql habit i got. thanks. On 23 Nov, 17:13, Matt Jones <al2o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 22, 11:44 am, eugenio <eugenio.mode...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i noticed that rails create signed int(11) for id fields (i''m using > > mysql, i don''t know if it acts like this with different databases). > > i think that unsigned is better for primary keys (and foreign keys). > > Is there an easy way to indicate that in a migration? > > There''s not a way to do so, as far as I know. Somewhat offtopic, why > do you believe that unsigned is preferable? Yes, it has twice as much > range, but if your DB has 2 billion objects in it and needs more - > you''ve likely got other problems...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
On Mon, Nov 23, 2009 at 10:13 AM, Matt Jones <al2o3cr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There''s not a way to do so, as far as I know. Somewhat offtopic, why > do you believe that unsigned is preferable? Yes, it has twice as much > range, but if your DB has 2 billion objects in it and needs more - > you''ve likely got other problems...When I know up front I will never store a negative value in there I change it to unsigned using an execute statement. It has nothing to do with capacity but has everything to do with data integrity. -- Greg Donald http://destiney.com/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.