Reputation: 206
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
@UniqueEntity({"store_id","user_id"})
php app/console doctrine:schema:update --force
Nothing to update - your database is already in sync with the current entity metadata.
I tried to delete and create the table again, there is no unique key created.
Upvotes: 1
Views: 649
Reputation: 7165
Try:
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
@UniqueEntity(fields={"store_id","user_id"})
Bear in mind the validator has nothing to do with the underlying database schema, it just validates the current state of the object. If you want to create a custom unique index consult the @UniqueConstraint annotation in doctrine:
/**
* @Entity
* @Table(name="ecommerce_products",uniqueConstraints={@UniqueConstraint(name="search_idx", columns={"store_id", "user_id"})})
*/
class ECommerceProduct
{
}
Upvotes: 1