Data too long for column for "string"

I already understand that the error is because a string that is too long was entered and that it can be solved, for example, by adding "->maxLength(255)". However, my question is, shouldn't the maximum be 255 by default? πŸ€”
No description
No description
5 Replies
tominal
tominalβ€’3mo ago
What if I increase the varchar on a column to 1000 characters in a later migration though?
LeandroFerreira
LeandroFerreiraβ€’3mo ago
no, you need to set maxLength
Dennis Koch
Dennis Kochβ€’3mo ago
I think the default in Laravel is 191 or 194
toeknee
toekneeβ€’3mo ago
Or just use text or longtext ?
awcodes
awcodesβ€’2mo ago
The max for string columns at the db level is 255 characters. But there is an issue in MySQL versions < 5.7 where you need to be conscious of it. It boils down to the encoding of the column. https://laracasts.com/discuss/channels/laravel/when-i-migrate-files-it-only-shows-varchar191-instead-of-255
Laracasts
Want results from more Discord servers?
Add your server