如果要添加多個唯一組合索引的話 use Doctrine\ORM\Mapping\UniqueConstraint 取多個別名應該可以
namespace App\Entity;
use App\Repository\AccountRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
#[ORM\Entity(repositoryClass: AccountRepository::class)]
#[UniqueConstraint(name:"account_ux", fields:["type", "value"])] // 這一行定義一個唯一索引實例的初始化參數
#[ORM\Table(uniqueConstraints: [UniqueConstraint::class])] // 這一行定義table需要添加的唯一索引
class Account
{
const TYPE_ACCOUNT = 0;
const TYPE_EMAIL = 1;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'smallint')]
private $type;
#[ORM\Column(type: 'string', length: 255)]
private $value;
#[ORM\Column(type: 'string', length: 13, unique: true)]
private $userId;
#[ORM\Column(type: 'boolean')]
private $enabled;
#[ORM\Column(type: 'integer')]
private $createTime;
#[ORM\Column(type: 'string', length: 255)]
private $createUser;
#[ORM\Column(type: 'integer')]
private $updateTime;
#[ORM\Column(type: 'string', length: 255)]
private $updateUser;
#[ORM\Column(type: 'string', length: 255)]
private $updateIp;
....