The method of modifying the enumeration type enum in the laravel framework

public  function  up ()
 {
    // Just add this sentence 
 Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping( 'enum' , 'string' );

 Schema::table('contract_records', function (Blueprint $table) {
     $table->string('level')->change();
    });
}

[Schema]::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping(‘enum’, ‘string’);

public  function  up ()
 {
    // Just add this sentence 
 Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping( 'enum' , 'string' );

 Schema::table('contract_records', function (Blueprint $table) {
     $table->string('level')->change();
    });
}

This method may then report an error, and no suitable solution has been found. If there is no error, then congratulations. . . .

If an error is reported, write sql directly to force the modification.

sql: ALTER TABLE contract_records (table name) MODIFY COLUMN level (field name) [enum] MODIFY COLUMN level (field name) [enum] (‘0′,’1′,’2′,’3′,’4′,’5′,’6’);

Leave a Comment

Your email address will not be published. Required fields are marked *