feat: Provisionner automatiquement un nouvel établissement
Some checks failed
CI / Backend Tests (push) Has been cancelled
CI / Frontend Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Naming Conventions (push) Has been cancelled
CI / Build Check (push) Has been cancelled

Lorsqu'un super-admin crée un établissement via l'interface, le système
doit automatiquement créer la base tenant, exécuter les migrations,
créer le premier utilisateur admin et envoyer l'invitation — le tout
de manière asynchrone pour ne pas bloquer la réponse HTTP.

Ce mécanisme rend chaque établissement opérationnel dès sa création
sans intervention manuelle sur l'infrastructure.
This commit is contained in:
2026-04-08 13:55:41 +02:00
parent bec211ebf0
commit 18c54e6d67
106 changed files with 9586 additions and 380 deletions

View File

@@ -38,6 +38,7 @@ final class Establishment extends AggregateRoot
public static function creer(
string $name,
string $subdomain,
string $adminEmail,
SuperAdminId $createdBy,
DateTimeImmutable $createdAt,
): self {
@@ -49,7 +50,7 @@ final class Establishment extends AggregateRoot
name: $name,
subdomain: $subdomain,
databaseName: sprintf('classeo_tenant_%s', str_replace('-', '', (string) $tenantId)),
status: EstablishmentStatus::ACTIF,
status: EstablishmentStatus::PROVISIONING,
createdAt: $createdAt,
createdBy: $createdBy,
);
@@ -59,12 +60,18 @@ final class Establishment extends AggregateRoot
tenantId: $establishment->tenantId,
name: $name,
subdomain: $subdomain,
adminEmail: $adminEmail,
occurredOn: $createdAt,
));
return $establishment;
}
public function activer(): void
{
$this->status = EstablishmentStatus::ACTIF;
}
public function desactiver(DateTimeImmutable $at): void
{
if ($this->status !== EstablishmentStatus::ACTIF) {