Symfony,继承的实体和学说迁移

问题描述 投票:2回答:1

Symfony 5.0]下,我使用通用实体类来统一内部项目。我的通用实体(例如表格)如下所示:


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\TableRepository")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorMap({"generic_table": "App\Entity\Generic\Table", "table": "App\Entity\Table"})
 */
class Site
{
    //protected properties and public methods
}

和继承的类:


use App\Entity\Generic\Table as GenericTable;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\TableRepository")
 */
class Table extends GenericTable
{
    //private properties and public methods
}

但是,执行此命令时:

php bin/console make:migration

它返回以下内容:

Table mybd.table already exists.

即使表没有。

有什么想法吗?我忘记了ORM声明吗?

在Symfony 5.0中,我使用通用实体类来统一内部项目。我的通用实体(例如表格)如下所示:use Doctrine \ Common \ Collections \ ArrayCollection;使用Doctrine \ Common \ ...

php doctrine-orm database-migration single-table-inheritance symfony5
1个回答
0
投票

线索:我们必须在@ORM \ Table注释上定义不同的表名:

© www.soinside.com 2019 - 2024. All rights reserved.