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)'); + } +}