Reputation: 59
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 try to modify a column's size, I get the error below:
[Doctrine\DBAL\DBALException]
Unknown database type point requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.
Here are 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();
});
}
Can anyone please help me with this?
Upvotes: 5
Views: 7939
Reputation: 1
I just used the accepted answer from @Ali Khalili and @miken32 for a model with a point field, which worked a treat. However, I got a deprecation warning for getDoctrineSchemaManager()->getDatabasePlatform()
.
Changed to getDoctrineConnection()->getDatabasePlatform()
, this is using doctrine/dbal 3.9.x
Upvotes: 0
Reputation: 1
If you suddenly get this problem on Symfony, try to delete the var folder to reset the cache, and execute the command one more time to see if it works.
Upvotes: 0
Reputation: 1684
In your migration, add the following function:
public function __construct()
{
\Illuminate\Support\Facades\DB::getDoctrineSchemaManager()
->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'string');
}
Upvotes: 9