Laravel 5 transitions: the default length of various types in the Schema :: table method

I set up migration to Laravel 5 and wondered if there is any default documentation for each of the column types? Do they follow some kind of convention like MySQL?

Example: INTEGER, TEXT, MEDIUMTEXT, LONGTEXT

I am talking about these types of columns: ( http://laravel.com/docs/5.0/schema#adding-columns )

+8
source share
3 answers

Here is the Laravel documentation link for column types

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

From the documentation, I assume that the default value of 255 is superimposed on the string () and char () methods, as can be seen from

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

Hope this helps!

+7
source

Range INTEGER 0-4294967295 (unsigned) or from -2147483648 to 2147483647 (signed) of the source

TEXT maximum size 65,535 characters source

MEDIUMTEXT maximum size 16,777,215 characters source

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

You can find more on the MySQL site, which seems to have been used by Laravel's authors.

+2
source

Line types

CHAR - 1 to 191 (trailing spaces removed)

STRING - 1 to 16,300 (user defined)

TEXT - 1 to 65,535

MIDDLE TEXT - 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: ([min to max decimal places], [min to max precision])

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

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

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

Note: decimal remembers the exact value when we print it to INT. See an example below:

 DOUBLE = DECIMAL = 2.65 //convert it to int DOUBLE = 2 DECIMAL = 3 


View all column types for laravel: documentation

+1
source

Source: https://habr.com/ru/post/1216576/


All Articles