Unique constraint definition #7438

Open
opened 2026-01-22 15:51:41 +01:00 by admin · 0 comments
Owner

Originally created by @klosto on GitHub (Nov 11, 2024).

Bug Report

Error in unique constraint definition

Q A
Version 2.13.0

Summary

When I tried to define unique constraint in ORM\Table() annotation, it didn't even created any setting in migration. Then I tried to define it in separated annotation like #[ORM\UniqueConstraint] and it worked.

#[ORM\Table(
    name: 'address',
    uniqueConstraints: [
        new ORM\UniqueConstraint(name: 'UNIQUE_id_public', fields: ['id_public']),              // Doesn't work
        new ORM\UniqueConstraint(name: 'UNIQUE_primary', fields: ['id', 'primary'])
    ]
)]
#[ORM\UniqueConstraint(name:'UNIQUE_id_public', fields: ['publicId'])]                          // Works

Am I doing something wrong, or is it expected behavior?

Originally created by @klosto on GitHub (Nov 11, 2024). ### Bug Report Error in unique constraint definition | Q | A |-------------------------------------------- | ------ | Version | 2.13.0 #### Summary When I tried to define unique constraint in `ORM\Table()` annotation, it didn't even created any setting in migration. Then I tried to define it in separated annotation like #[ORM\UniqueConstraint] and it worked. ``` #[ORM\Table( name: 'address', uniqueConstraints: [ new ORM\UniqueConstraint(name: 'UNIQUE_id_public', fields: ['id_public']), // Doesn't work new ORM\UniqueConstraint(name: 'UNIQUE_primary', fields: ['id', 'primary']) ] )] #[ORM\UniqueConstraint(name:'UNIQUE_id_public', fields: ['publicId'])] // Works ``` Am I doing something wrong, or is it expected behavior?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7438