From ee006f55d6ff82f905d848ca3af4efbfd7957bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 26 Sep 2025 14:44:31 +0200 Subject: [PATCH] Add unique constraint for `definition_id` and `person_id` in `PersonIdentifier` - Update entity to include the new database-level unique constraint. - Add migration script to apply the unique constraint and handle rollback. --- .../Entity/Identifier/PersonIdentifier.php | 1 + .../migrations/Version20250926124024.php | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20250926124024.php diff --git a/src/Bundle/ChillPersonBundle/Entity/Identifier/PersonIdentifier.php b/src/Bundle/ChillPersonBundle/Entity/Identifier/PersonIdentifier.php index 0cd03472a..b0c79ccae 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Identifier/PersonIdentifier.php +++ b/src/Bundle/ChillPersonBundle/Entity/Identifier/PersonIdentifier.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] #[ORM\Table(name: 'chill_person_identifier')] #[ORM\UniqueConstraint(name: 'chill_person_identifier_unique', columns: ['definition_id', 'canonical'])] +#[ORM\UniqueConstraint(name: 'chill_person_identifier_unique_person_definition', columns: ['definition_id', 'person_id'])] #[UniqueIdentifierConstraint] class PersonIdentifier { diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20250926124024.php b/src/Bundle/ChillPersonBundle/migrations/Version20250926124024.php new file mode 100644 index 000000000..71630d0ad --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20250926124024.php @@ -0,0 +1,33 @@ +addSql('CREATE UNIQUE INDEX chill_person_identifier_unique_person_definition ON chill_person_identifier (definition_id, person_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP INDEX chill_person_identifier_unique_person_definition'); + } +}