Getting error [Doctrine\DBAL\DBALException] Unknown database type point requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it

Viewed 4902

I'm using laravel and I just added a new migration for increasing column size. The first generated table has a column named latlong of type Point. I can't modify any column size?

When I am trying to do this the below error is given. Can anyone please help me with this?

[Doctrine\DBAL\DBALException]
Unknown database type point requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

Here is my migration files.

First migration is for create a table abc

public function up()
{
 Schema::create('abc', function (Blueprint $table) {
        $table->increments('id');
        $table->string('first_name', 20);
        $table->string('last_name', 20);
        $table->string('street', 100);
        $table->string('city', 50)->nullable();
        $table->string('state', 50)->nullable();
        $table->string('postal_code', 15);
        $table->string('mobile', 10)->nullable();
        $table->timestamps();
        $table->softDeletes();
});   
Illuminate\Support\Facades\DB::statement('ALTER TABLE abc ADD latlong POINT');

}

Second migration is for update column size

public function up()
{
 Schema::table('abc', function (Blueprint $table){
     $table->string('mobile', 20)->nullable()->change();
 });
}
2 Answers

The solution is something like @AnhDam suggested. But your should never change the files in vendor directory of composer. Insead, in your migration, add the following function:

public function __construct()
{
    \Illuminate\Support\Facades\DB::getDoctrineSchemaManager()
       ->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'string');
}

Please try to add below in vendor\infyomlabs\laravel-generator\src\Utils\TableFieldsGenerator.php

$platform = $this->schemaManager->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('bit', 'boolean');

// Add new line $platform->registerDoctrineTypeMapping('point', 'string');

Related