Laravel 数据库模式中的 MediumBlob [英] MediumBlob in Laravel database schema

查看:47
本文介绍了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");

这篇关于Laravel 数据库模式中的 MediumBlob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆