Laravel 5 migrations : default length of different types in Schema::table method

String types

CHAR - 1 to 191 (trailing spaces removed)

STRING - 1 to 16,300 (user defined)

TEXT - 1 to 65,535

MEDIUMTEXT - 1 to 16,777,215

LONGTEXT - 1 to 4,294,967,295


Integer types

TINYINT - 0 to 255 (unsigned) | -128 to 127 (signed)

SMALLINT - 0 to 65,535 (unsigned) | -32,768 to 32,767 (signed)

MEDIUMINT - 0 to 16,777,215 (unsigned) | -8,388,608 to 8,388,607 (signed)

INT - 0 to 4,294,967,295 (unsigned) | -2,147,483,648 to 2,147,483,647 (signed)

BIGINT - 0 to 18,446,744,073,709,551,615 (unsigned) | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed)


Floating types

Structure: `([max decimal places], [max precision])`

FLOAT - ([0-7], [0-23])

DOUBLE - ([0-14], [24-53])

DECIMAL - ([0-65], [0-30])

Note: decimal stores exact value when we print it in INT. See example below:

DOUBLE = DECIMAL = 2.65

//convert it to int

DOUBLE = 2

DECIMAL = 3

See all column type for laravel: documentation


Here is the Laravel documentation link for the column types

http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html

From the documentation, I guess the default of 255 is imposed on string() and char() methods as evident from

http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html#method_string

Hope this helps!


INTEGER range 0-4294967295 (unsigned) or from -2147483648 to 2147483647 (signed) source

TEXT max size 65,535 characters source

MEDIUMTEXT max size 16,777,215 characters source

LONGTEXT max size 4,294,967,295 characters source

More you can find on mysql site which looks like was used by laravel authors.

Tags:

Mysql

Laravel