Laravel 数据库模式中的 MediumBlob
如何在 Laravel 架构构建器中创建 Mediumblob
?
How can I create a Mediumblob
within the Laravel schema builder ?
在文档中它说:
$table->binary('data'); // BLOB equivalent to the table
但我需要一个 MediumBlob,否则图像会在 64K 时被截断;我们正在运行 MySQL.
But I need a MediumBlob otherwise the images get truncated at 64K; we are running MySQL.
我知道 Laravel 的架构构建器与数据库无关,但有没有办法避免原生方式",如果没有,我该如何创建 Mediumblob
列?
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 ?
推荐答案
你不能.
这个 issue 建议使用原始查询来创建此类列,因此您应该在迁移中执行类似的操作文件:
This issue suggests using raw queries to create such columns, so you should do something like this in your migration file :
Schema::create("<table name>", function($table) {
// here you do all columns supported by the schema builder
});
// once the table is created use a raw query to ALTER it and add the MEDIUMBLOB
DB::statement("ALTER TABLE <table name> ADD <column name> MEDIUMBLOB");
相关文章