如何在Laravel架构构建器中创建Mediumblob
?
在文档中说:
$table->binary('data'); // BLOB equivalent to the table
但我需要一个MediumBlob,否则图像会被截断为64K;我们正在运行MySQL。
我知道Laravel的架构生成器与数据库无关,但有没有办法避免“本机方式”,如果不能,我怎样才能创建Mediumblob
列?
答案 0 :(得分:28)
你不能。
此issue建议使用原始查询来创建此类列,因此您应该在迁移文件中执行以下操作:
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");
答案 1 :(得分:-2)
已创建字段但无法插入文件。并导致以下错误:
#1118 - Row size too large (> 8126)
将某些列更改为TEXT或BLOB或使用ROW_FORMAT=DYNAMIC
或ROW_FORMAT=COMPRESSED
可能有所帮助。在当前行格式中,760字节的BLOB前缀以内联方式存储。