From 111906c2b9599fd99c3f5801811e7aea840b9116 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 25 Apr 2022 11:23:28 +0200 Subject: [PATCH] person: add unique index on table relationship to avoid duplicate fromperson_id/toperson_id pairs --- .../migrations/Version20220425000000.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220425000000.php diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220425000000.php b/src/Bundle/ChillPersonBundle/migrations/Version20220425000000.php new file mode 100644 index 000000000..2feb246bd --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220425000000.php @@ -0,0 +1,37 @@ +addSql('DROP INDEX IDX_RELATIONSHIPS000'); + } + + public function getDescription(): string + { + return 'Add constraint with a index on chill_person_relationships.'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE UNIQUE INDEX IDX_RELATIONSHIPS000 ON chill_person_relationships (least(fromperson_id, toperson_id), greatest(fromperson_id, toperson_id))'); + } +} +