mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-26 15:48:07 +00:00
Resolve "Ajout d'un champ "externalId" pour les centres"
This commit is contained in:
7
.changes/unreleased/Feature-20260324-164018.yaml
Normal file
7
.changes/unreleased/Feature-20260324-164018.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
kind: Feature
|
||||
body: Add a field "externalId" on center, to ease the synchronisation of centers with external tools
|
||||
time: 2026-03-24T16:40:18.159561269+01:00
|
||||
custom:
|
||||
Issue: "507"
|
||||
MR: "977"
|
||||
SchemaChange: Add columns or tables
|
||||
@@ -45,6 +45,9 @@ class Center implements HasCenterInterface, \Stringable
|
||||
#[ORM\ManyToMany(targetEntity: Regroupment::class, mappedBy: 'centers')]
|
||||
private Collection $regroupments;
|
||||
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])]
|
||||
private string $externalId = '';
|
||||
|
||||
/**
|
||||
* Center constructor.
|
||||
*/
|
||||
@@ -124,4 +127,19 @@ class Center implements HasCenterInterface, \Stringable
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExternalId(): string
|
||||
{
|
||||
return $this->externalId;
|
||||
}
|
||||
|
||||
public function setExternalId(string $externalId): void
|
||||
{
|
||||
$this->externalId = $externalId;
|
||||
}
|
||||
|
||||
public function hasExternalId(): bool
|
||||
{
|
||||
return '' !== $this->externalId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ final readonly class CenterRepository implements CenterRepositoryInterface
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneByExternalId(string $externalId): ?Center
|
||||
{
|
||||
return $this->repository->findOneBy(['externalId' => $externalId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Center[]
|
||||
*/
|
||||
|
||||
@@ -24,4 +24,6 @@ interface CenterRepositoryInterface extends ObjectRepository
|
||||
* @return Center[]
|
||||
*/
|
||||
public function findActive(): array;
|
||||
|
||||
public function findOneByExternalId(string $externalId): ?Center;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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 Version20260324144420 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add an external id for centers';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE public.centers ADD externalId TEXT DEFAULT \'\' NOT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX centers_external_id_unique ON public.centers (externalId) WHERE externalId <> \'\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX public.centers_external_id_unique');
|
||||
$this->addSql('ALTER TABLE public.centers DROP externalId');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user