In this post il will show how to configure Doctrine UniqueConstraint when you have SoftDeleteable extension.
* @ORM\Table( * name="persons", * uniqueConstraints={ * @ORM\UniqueConstraint(name="user_unique_username", * columns={"username","account_id"}, * options={"where":"(deleted_at IS NULL)"} * ), * }, * ) * @Gedmo\SoftDeleteable()
This unique index will look like this in SQL :
CREATE UNIQUE INDEX user_unique_username ON public.persons USING btree (username, account_id) WHERE (deleted_at IS NULL);