Symfony 6 中的单列索引

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

有一个字段:

#[ORM\Column(length: 255, nullable: true, )]
private ?string $inn = null;

如何通过迁移添加单列索引以避免 Symfony 中的错误。

我尝试在官方学说网站上查找有关此内容的文档,但只找到有关实体之间关系索引的信息。

symfony doctrine-orm
1个回答
0
投票

在类的顶部,添加类似这样的内容

#[ORM\Index(columns: ['inn'], name: 'application_inn_idx')]

然后生成迁移

symfony console make:migration

然后运行迁移

symfony console doctrine:migration:migrate
© www.soinside.com 2019 - 2024. All rights reserved.