Resolve "Des codes postaux marqués comme supprimés apparaissent toujours dans la recherche d'adresse"

This commit is contained in:
2026-02-23 14:16:45 +00:00
parent 76d675ac02
commit f1446d7abe
4 changed files with 54 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
kind: Fixed
body: |
Fix: some postal code appears in the UI, although they are marked as deleted
time: 2026-02-23T14:47:35.925109983+01:00
custom:
Issue: "499"
MR: "963"
SchemaChange: No schema change

View File

@@ -79,5 +79,7 @@ final class PostalCodeAPIController extends ApiController
$qb->andWhere('e.origin = :zero')
->setParameter('zero', 0);
$qb->andWhere('e.deletedAt IS NULL');
}
}

View File

@@ -100,7 +100,9 @@ final readonly class PostalCodeRepository implements PostalCodeRepositoryInterfa
$query
->setFromClause('chill_main_postal_code cmpc')
->andWhereClause('cmpc.origin = 0');
->andWhereClause('cmpc.origin = 0')
->andWhereClause('cmpc.deletedAt IS NULL')
;
if (null !== $country) {
$query->andWhereClause('cmpc.country_id = ?', [$country->getId()]);

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260223134919 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create a partial index for postal_code search_name_code, to avoid deleted records';
}
public function up(Schema $schema): void
{
$this->addSql('DROP INDEX public.search_name_code');
$this->addSql('CREATE INDEX search_name_code ON public.chill_main_postal_code USING GIN (LOWER(code) gin_trgm_ops, LOWER(label) gin_trgm_ops) WHERE deletedAt IS NULL');
$this->addSql('DROP INDEX public.chill_internal_postal_code_canonicalized');
$this->addSql('CREATE INDEX chill_internal_postal_code_canonicalized ON chill_main_postal_code USING GIST (canonical gist_trgm_ops) WHERE origin = 0 AND deletedAt IS NULL');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX public.search_name_code');
$this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code USING GIN (LOWER(code) gin_trgm_ops, LOWER(label) gin_trgm_ops)');
$this->addSql('DROP INDEX public.chill_internal_postal_code_canonicalized');
$this->addSql('CREATE INDEX chill_internal_postal_code_canonicalized ON chill_main_postal_code USING GIST (canonical gist_trgm_ops) WHERE origin = 0');
}
}