The upgrade notes for Laravel 11 say:
The float column type now creates a
FLOAT
equivalent column without total digits and places (digits after decimal point), but with an optional$precision
specification to determine storage size as a 4-byte single-precision column or an 8-byte double-precision column. Therefore, you may remove the arguments for$total
and$places
and specify the optional$precision
to your desired value and according to your database's documentation:$table->float('amount', precision: 53);
However, the database documentation doesn't provide any explanation for what the precision
argument might represent or why it defaults to 53. What effect will changing the value have on the resulting column?
Wasn't planning on a self-answer, but I thought to check MySQL's documentation and got an answer:
For
FLOAT
, the SQL standard permits an optional specification of the precision (but not the range of the exponent) in bits following the keywordFLOAT
in parentheses, that is,FLOAT(p)
. MySQL also supports this optional precision specification, but the precision value inFLOAT(p)
is used only to determine storage size. A precision from 0 to 23 results in a 4-byte single-precisionFLOAT
column. A precision from 24 to 53 results in an 8-byte double-precisionDOUBLE
column.
So I think this means my old migrations with $table->float('price', 6)
should continue to work as expected.