From 3a115744fe4a19880d7b5676b8497b9eff8e4fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 6 May 2022 17:14:05 +0200 Subject: [PATCH] add index to search postal code by reference --- .../ChillMainBundle/Entity/PostalCode.php | 9 ++--- .../migrations/Version20220506145935.php | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20220506145935.php diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index 484a9e322..4569915b4 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -21,10 +21,11 @@ use Symfony\Component\Serializer\Annotation\Groups; * @ORM\Entity * @ORM\Table( * name="chill_main_postal_code", - * indexes={@ORM\Index( - * name="search_name_code", - * columns={"code", "label"} - * )}) + * indexes={ + * @ORM\Index(name="search_name_code", columns={"code", "label"}), + * @ORM\Index(name="search_by_reference_code", colums={"code", "refpostalcodeid"}) + * }) + * * @ORM\HasLifecycleCallbacks */ class PostalCode diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220506145935.php b/src/Bundle/ChillMainBundle/migrations/Version20220506145935.php new file mode 100644 index 000000000..9df382214 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20220506145935.php @@ -0,0 +1,33 @@ +addSql('DROP INDEX search_by_reference_code'); + } + + public function getDescription(): string + { + return 'Add index to search postal code by references'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE INDEX search_by_reference_code ON chill_main_postal_code (code, refpostalcodeid)'); + } +}