Search code examples
databaselaravellaravel-5fieldclob

Laravel add CLOB column


Hey I've searched everywhere on google and In Laravel documentation and I couldn't find how can I add CLOB field to the table. Is it possible?

$table->clob('test'); 

Isn't working.


Solution

  • Laravel's schema manager doesn't support all column types.

    Medium and long blobs arent supported so I guess cblob isnt any aswell

    https://github.com/laravel/framework/issues/3544

    There is a way to do it raw quires DB::statement in a migration.

    Take a look at this answer

    MediumBlob in Laravel database schema

    TL;DR

    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");