11

Once and for all: Rails migrations integer :limit option

 3 years ago
source link: https://www.devroom.io/2009/08/20/once-and-for-all-rails-migrations-integer-limit-option/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Once and for all: Rails migrations integer :limit option

Posted: 2009-08-20 - Last updated: 2019-06-05

Tagged mysql ruby on rails rails sql migrations integer limit

I literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here’s an overview. Now let’s memorise it (oh, this works for MySQL, other databases may work differently):

:limit Numeric Type Column Size Max value 1 tinyint 1 byte 127 2 smallint 2 bytes 32767 3 mediumint 3 byte 8388607 nil, 4, 11 int(11) 4 byte 2147483647 5..8 bigint 8 byte 9223372036854775807

Note: by default MySQL uses signed integers and Rails has no way (that I know of) to change this behaviour. Subsequently, the max. values noted are for signed integers.

My site is free of ads and trackers. I record privacy-respecting usage statistics with Fathom.

Was this post helpful to you? Why not ☕ Buy me a coffee

Copyright © 1999-2020 Ariejan de Vroom <[email protected]>

Live now; make now always the most precious time. Now will never come again.
    – Jean-Luc Picard


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK