1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 20:54:02 +00:00

If harden throws an exception, revert connection back to central

This commit is contained in:
lukinovec 2026-05-01 12:08:02 +02:00
parent f5f5f1d4aa
commit 52f6857302
2 changed files with 17 additions and 1 deletions

View file

@ -51,7 +51,16 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
$this->database->connectToTenant($tenant);
if (static::$harden) $this->harden($tenant);
try {
if (static::$harden) {
$this->harden($tenant);
}
} catch (RuntimeException $e) {
// Revert connection back to central
$this->revert();
throw $e;
}
}
public function revert(): void