rails migration中integer column的limit
2014-11-13 10:05:47

integer的limit其實指的是byte的長度,而不是字串的長度,下面是對應表:

:limitSQL的資料型態大小最大值
1tinyint1 byte127
2smallint2 byte32767
3mediumint3 byte8388607
nil, 4, 11int(11)4 byte2147483647
5..8bigint8 byte9223372036854775807

Refs

Once and for all: Rails migrations integer :limit option