fix(command): enhance database deletion command to support multiple database types
This commit is contained in:
parent
339118558c
commit
b17c65b224
1 changed files with 36 additions and 3 deletions
|
|
@ -6,7 +6,14 @@
|
|||
use App\Models\Application;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\Models\StandaloneClickhouse;
|
||||
use App\Models\StandaloneDragonfly;
|
||||
use App\Models\StandaloneKeydb;
|
||||
use App\Models\StandaloneMariadb;
|
||||
use App\Models\StandaloneMongodb;
|
||||
use App\Models\StandaloneMysql;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use App\Models\StandaloneRedis;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
|
|
@ -103,14 +110,40 @@ private function deleteApplication()
|
|||
|
||||
private function deleteDatabase()
|
||||
{
|
||||
$databases = StandalonePostgresql::all();
|
||||
$databaseType = select(
|
||||
'What type of database do you want to delete?',
|
||||
[
|
||||
'PostgreSQL' => 'PostgreSQL',
|
||||
'MySQL' => 'MySQL',
|
||||
'MariaDB' => 'MariaDB',
|
||||
'MongoDB' => 'MongoDB',
|
||||
'Redis' => 'Redis',
|
||||
'KeyDB' => 'KeyDB',
|
||||
'Dragonfly' => 'Dragonfly',
|
||||
'ClickHouse' => 'ClickHouse',
|
||||
],
|
||||
);
|
||||
|
||||
$databases = match ($databaseType) {
|
||||
'PostgreSQL' => StandalonePostgresql::all(),
|
||||
'MySQL' => StandaloneMysql::all(),
|
||||
'MariaDB' => StandaloneMariadb::all(),
|
||||
'MongoDB' => StandaloneMongodb::all(),
|
||||
'Redis' => StandaloneRedis::all(),
|
||||
'KeyDB' => StandaloneKeydb::all(),
|
||||
'Dragonfly' => StandaloneDragonfly::all(),
|
||||
'ClickHouse' => StandaloneClickhouse::all(),
|
||||
default => collect(),
|
||||
};
|
||||
|
||||
if ($databases->count() === 0) {
|
||||
$this->error('There are no databases to delete.');
|
||||
$this->error("There are no {$databaseType} databases to delete.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$databasesToDelete = multiselect(
|
||||
'What database do you want to delete?',
|
||||
"What {$databaseType} database do you want to delete?",
|
||||
$databases->pluck('name', 'id')->sortKeys(),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue