Jai*_*and 5 php doctrine doctrine-orm laravel laravel-5.4
我正在使用laravel,我刚刚添加了一个新的迁移来增加列大小。第一个生成的表有一个名为latlongtype的列Point。我不能修改任何列大小?
当我尝试执行此操作时,会出现以下错误。任何人都可以帮我解决这个问题吗?
[Doctrine\DBAL\DBALException]
请求未知的数据库类型点,Doctrine\DBAL\Platforms\MySQL57Platform 可能不支持它。
这是我的迁移文件。
第一次迁移是为了创建一个表 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');
}
Run Code Online (Sandbox Code Playgroud)
第二次迁移用于更新列大小
public function up()
{
Schema::table('abc', function (Blueprint $table){
$table->string('mobile', 20)->nullable()->change();
});
}
Run Code Online (Sandbox Code Playgroud)
解决方案就像@AnhDam 建议的那样。但是您永远不应该更改 composer.json 的 vendor 目录中的文件。Insead,在您的迁移中,添加以下函数:
public function __construct()
{
\Illuminate\Support\Facades\DB::getDoctrineSchemaManager()
->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'string');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3180 次 |
| 最近记录: |