Files
coolify/app/Livewire/Project/Database/Backup/Execution.php
T
Andras BacsaiandClaude Opus 5.5 9c6138fe18 fix(cleanup): stop loading deployment logs and unused backup executions
The stuck resources cleanup selected every column of every deployment,
including logs, and ran out of memory during app:init. Select only the
id and application_id. Also drop the unused executions property on the
backup pages and an unused execution loader.

Closes #12435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 18:14:23 +01:00

119 lines
3.5 KiB
PHP

<?php
namespace App\Livewire\Project\Database\Backup;
use App\Livewire\Concerns\ManagesDatabaseBackup;
use App\Livewire\Project\Database\BackupEdit;
use App\Models\S3Storage;
use App\Models\ScheduledDatabaseBackup;
use App\Traits\ListensToTeamChannel;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Livewire\Features\SupportRedirects\Redirector;
class Execution extends Component
{
use AuthorizesRequests;
use ListensToTeamChannel;
use ManagesDatabaseBackup;
public $database;
public ?ScheduledDatabaseBackup $backup;
public $s3s;
public array $parameters = [];
public string $section = 'general';
public function getListeners(): array
{
// Keep the header backup actions in sync when the database starts/stops.
$listeners = [
'databaseUpdated' => '$refresh',
'backupEnabledChanged' => 'syncBackupEnabled',
];
$user = Auth::user();
if ($user) {
$listeners["echo-private:user.{$user->id},DatabaseStatusChanged"] = '$refresh';
}
return [
...$listeners,
...$this->teamChannelListeners([
'ServiceChecked' => '$refresh',
'ServiceStatusChanged' => '$refresh',
]),
];
}
public function mount()
{
$backup_uuid = request()->route('backup_uuid');
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (! $project) {
return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first();
if (! $environment) {
abort(404);
}
$environment->load(['applications']);
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
if (! $database) {
return redirect()->route('dashboard');
}
$backup = $database->scheduledBackups->where('uuid', $backup_uuid)->first();
if (! $backup) {
return redirect()->route('dashboard');
}
$this->database = $database;
$this->backup = $backup;
$this->s3s = S3Storage::query()
->where('team_id', $database->team()->id)
->where('is_usable', true)
->get();
$this->parameters = get_route_parameters();
$this->section = match (request()->route()?->getName()) {
'project.database.backup.executions' => 'executions',
'project.database.backup.danger' => 'danger',
default => 'general',
};
}
public function backupNow(): Redirector|RedirectResponse|null
{
try {
return $this->queueDatabaseBackup($this->backup);
} catch (\Throwable $e) {
handleError($e, $this);
return null;
}
}
public function toggleEnabled(): void
{
try {
$this->toggleDatabaseBackup($this->backup);
$this->dispatch('backupEnabledChanged')->to(BackupEdit::class);
} catch (\Throwable $e) {
$this->dispatch('error', $e->getMessage());
}
}
public function syncBackupEnabled(): void
{
$this->backup->refresh();
}
public function render()
{
return view('livewire.project.database.backup.execution');
}
}