feat(commands): include sqlite in cleanup and delete commands

This commit is contained in:
peaklabs-dev
2026-09-24 19:03:43 +02:00
parent 92f8b806ea
commit 6c65df0b68
4 changed files with 21 additions and 0 deletions
+2
View File
@@ -18,6 +18,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use App\Models\StandaloneSqlite;
use App\Models\Tag;
use App\Models\Team;
use App\Support\ValidationPatterns;
@@ -49,6 +50,7 @@ class CleanupNames extends Command
'StandaloneKeydb' => StandaloneKeydb::class,
'StandaloneDragonfly' => StandaloneDragonfly::class,
'StandaloneClickhouse' => StandaloneClickhouse::class,
'StandaloneSqlite' => StandaloneSqlite::class,
'S3Storage' => S3Storage::class,
'Tag' => Tag::class,
'PrivateKey' => PrivateKey::class,
@@ -21,6 +21,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use App\Models\StandaloneSqlite;
use App\Models\Team;
use Illuminate\Console\Command;
@@ -180,6 +181,15 @@ class CleanupStuckedResources extends Command
} catch (\Throwable $e) {
echo "Error in cleaning stuck mariadb: {$e->getMessage()}\n";
}
try {
$sqlites = StandaloneSqlite::withTrashed()->whereNotNull('deleted_at')->lazyById();
foreach ($sqlites as $sqlite) {
echo "Deleting stuck sqlite: {$sqlite->name}\n";
DeleteResourceJob::dispatch($sqlite);
}
} catch (\Throwable $e) {
echo "Error in cleaning stuck sqlite: {$e->getMessage()}\n";
}
try {
$services = Service::withTrashed()->whereNotNull('deleted_at')->lazyById();
foreach ($services as $service) {
@@ -77,6 +77,7 @@ class CleanupUnverifiedUsers extends Command
->orWhereHas('projects.keydbs')
->orWhereHas('projects.dragonflies')
->orWhereHas('projects.clickhouses')
->orWhereHas('projects.sqlites')
->orWhereHas('projects.services');
});
}
+8
View File
@@ -14,6 +14,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use App\Models\StandaloneSqlite;
use Illuminate\Console\Command;
use function Laravel\Prompts\confirm;
@@ -170,6 +171,13 @@ class ServicesDelete extends Command
$databaseOptions->put($key, "{$db->name} (ClickHouse)");
}
// Add SQLite databases
foreach (StandaloneSqlite::all() as $db) {
$key = "sqlite_{$db->id}";
$allDatabases->put($key, $db);
$databaseOptions->put($key, "{$db->name} (SQLite)");
}
if ($allDatabases->count() === 0) {
$this->error('There are no databases to delete.');