Under Symfony 5.0 , I use generic entity classes to unify internal projects. My generic entity (eg Table) looks like this:
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
}
And inherited class:
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
}
However, when executing this command:
php bin/console make:migration
It returns the following:
Table mybd.table already exists.
Even if the table doesn't.
Any idea? Have I forgotten an ORM statement?
A lead: we must define different table names on @ORM\\Table annotation:
@ORM\\Table(name="generic_table")
for class Table
@ORM\\Table(name="table")
for class Table extends GenericTable
Finally, it only creates in database table generic_table
and redefines constraints on this table. But I still have issues with Repositories...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.