This commit is contained in:
Andras Bacsai 2023-11-06 10:45:06 +01:00
parent 3f8514050e
commit 2c6ece62bb
4 changed files with 45 additions and 28 deletions

View File

@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Actions\Database\StopDatabase;
use App\Models\S3Storage;
use App\Models\ScheduledDatabaseBackup;
use App\Models\ScheduledDatabaseBackupExecution;
@ -22,6 +23,7 @@
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
use Throwable;
class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
{
@ -64,6 +66,14 @@ public function uniqueId(): int
public function handle(): void
{
try {
// Check if team is exists
if (is_null($this->team)) {
$this->backup->update(['status' => 'failed']);
StopDatabase::run($this->database);
$this->database->delete();
return;
}
$status = Str::of(data_get($this->database, 'status'));
if (!$status->startsWith('running') && $this->database->id !== 0) {
ray('database not running');

View File

@ -32,11 +32,11 @@ protected static function booted()
]);
});
static::deleting(function ($database) {
$database->scheduledBackups()->delete();
$storages = $database->persistentStorages()->get();
foreach ($storages as $storage) {
instant_remote_process(["docker volume rm -f $storage->name"], $database->destination->server, false);
}
$database->scheduledBackups()->delete();
$database->persistentStorages()->delete();
$database->environment_variables()->delete();
});

View File

@ -45,7 +45,7 @@ services:
- /data/coolify/_volumes/redis/:/data
# - coolify-redis-data-dev:/data
vite:
image: node:19
image: node:20
working_dir: /var/www/html
ports:
- "${VITE_PORT:-5173}:${VITE_PORT:-5173}"

View File

@ -11,8 +11,7 @@
<div>This is the default team. You can't delete it.</div>
@elseif(auth()->user()->teams()->get()->count() === 1)
<div>You can't delete your last team.</div>
@elseif(currentTeam()->subscription &&
currentTeam()->subscription?->lemon_status !== 'cancelled')
@elseif(currentTeam()->subscription && currentTeam()->subscription?->lemon_status !== 'cancelled')
<div>Please cancel your subscription before delete this team (Manage My Subscription).</div>
@else
@if (currentTeam()->isEmpty())
@ -23,30 +22,38 @@
@else
<div>
<div class="pb-4">You need to delete the following resources to be able to delete the team:</div>
<h4 class="pb-4">Projects:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->projects as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
<h4 class="py-4">Servers:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->servers as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
<h4 class="py-4">Private Keys:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->privateKeys as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
<h4 class="py-4">Sources:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->sources() as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
@if (currentTeam()->projects()->count() > 0)
<h4 class="pb-4">Projects:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->projects as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
@endif
@if (currentTeam()->servers()->count() > 0)
<h4 class="py-4">Servers:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->servers as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
@endif
@if (currentTeam()->privateKeys()->count() > 0)
<h4 class="py-4">Private Keys:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->privateKeys as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
@endif
@if (currentTeam()->sources()->count() > 0)
<h4 class="py-4">Sources:</h4>
<ul class="pl-8 list-disc">
@foreach (currentTeam()->sources() as $resource)
<li>{{ $resource->name }}</li>
@endforeach
</ul>
@endif
@endif
@endif