MediumBlob in Laravel database schema

后端 未结 2 1104
迷失自我
迷失自我 2020-12-06 10:42

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

In the docs it says :

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


        
相关标签:
2条回答
  • 2020-12-06 11:01

    You can't.

    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");
    
    0 讨论(0)
  • 2020-12-06 11:07

    The field is created but the file can not be inserted. And the following error is caused:

    #1118 - Row size too large (> 8126)

    Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format BLOB prefix of 768 bytes is stored inline.

    0 讨论(0)
提交回复
热议问题