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? π€


5 Replies
What if I increase the varchar on a column to 1000 characters in a later migration though?
no, you need to set
maxLength
I think the default in Laravel is 191 or 194
Or just use text or longtext ?
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