mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-22 19:22:19 +00:00
* fix: allow reuse of a database name * style --------- Co-authored-by: Saeed Vaziry <61919774+saeedvaziry@users.noreply.github.com> Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
26 lines
631 B
PHP
Executable File
26 lines
631 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Actions\Database;
|
|
|
|
use App\Models\Backup;
|
|
use App\Models\Database;
|
|
use App\Models\Server;
|
|
use App\Models\Service;
|
|
|
|
class DeleteDatabase
|
|
{
|
|
public function delete(Server $server, Database $database): void
|
|
{
|
|
/** @var Service $service */
|
|
$service = $server->database();
|
|
/** @var \App\SSH\Services\Database\Database $handler */
|
|
$handler = $service->handler();
|
|
$handler->delete($database->name);
|
|
$database->delete();
|
|
|
|
$database->backups()->each(function (Backup $backup): void {
|
|
app(ManageBackup::class)->stop($backup);
|
|
});
|
|
}
|
|
}
|