From 4b7e3c16019e18fef2aa0c262c2c5b4164537a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 Sep 2025 12:40:37 +0200 Subject: [PATCH] Restrict deletion of `identifier_definition` to prevent errors and ensure data integrity - Updated foreign key constraint on `chill_person_identifier.definition_id` to use `ON DELETE RESTRICT` instead of `ON DELETE CASCADE`. - Adjusted migration script to handle both the upgrade and downgrade paths for the new restriction. --- .../migrations/Version20250924101621.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20250924101621.php diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20250924101621.php b/src/Bundle/ChillPersonBundle/migrations/Version20250924101621.php new file mode 100644 index 000000000..e6f9fff54 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20250924101621.php @@ -0,0 +1,53 @@ +addSql(<<<'SQL' + ALTER TABLE chill_person_identifier DROP CONSTRAINT fk_bca5a36bd11ea911 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_identifier ADD CONSTRAINT fk_bca5a36bd11ea911 + FOREIGN KEY (definition_id) REFERENCES chill_person_identifier_definition (id) + on delete restrict + SQL); + + } + + public function down(Schema $schema): void + { + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_identifier DROP CONSTRAINT fk_bca5a36bd11ea911 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_identifier ADD CONSTRAINT fk_bca5a36bd11ea911 + FOREIGN KEY (definition_id) REFERENCES chill_person_identifier_definition (id) + on delete cascade + SQL); + } +}