Maybe the unique
parameter in the column annotation could help you?
#[ORM\Column(unique: true, name: "app_id", type: Types::BIGINT)]
private ?int $appId = null;
If the user is supposed to be unique, maybe a OneToOne
Relation could be better than a ManyToOne
. I am pretty sure using OneToOne
will also generate a unique index in your migration for you, even without the unique
parameter.
#[ORM\OneToOne(inversedBy: 'userMobileApp', cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(name: "user_id, "nullable: false)]
private ?User $user = null;