Search code examples
mysqldatabaselaravellaravel-4

MediumBlob in Laravel database schema


How can I create a Mediumblob within the Laravel schema builder ?

In the docs it says :

$table->binary('data'); // BLOB equivalent to the table

But I need a MediumBlob otherwise the images get truncated at 64K; we are running MySQL.

I know that Laravel's schema builder is DB agnostic, but is there a way to avoid the "native way" and if not how can i create a Mediumblob column ?


Solution

  • Starting from Laravel 11.x you can now create a longer (or shorter) BLOB with this statement.

    I tested this on Laravel 10.x, and it works just fine. Probably need to test in previous versions, but as this is a SQL statement, not a Laravel specific behavior, it must work.

    $table->mediumText('data')->charset('binary'); // MEDIUMBLOB