From b282c1f3ed64604c826f78a678963a7f046262d2 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:20:26 +0100 Subject: [PATCH 1/3] fix backup job without s3 can not be added --- app/Livewire/Project/Database/CreateScheduledBackup.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Project/Database/CreateScheduledBackup.php b/app/Livewire/Project/Database/CreateScheduledBackup.php index 0903efdfd..e7bb451f6 100644 --- a/app/Livewire/Project/Database/CreateScheduledBackup.php +++ b/app/Livewire/Project/Database/CreateScheduledBackup.php @@ -21,8 +21,8 @@ class CreateScheduledBackup extends Component public bool $enabled = true; - #[Validate(['required', 'integer'])] - public int $s3StorageId; + #[Validate(['nullable', 'integer'])] + public ?int $s3StorageId = null; public Collection $definedS3s; From 67bd06d4f2b0c6fbd0c1ae863fc254c5f343384d Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:25:04 +0100 Subject: [PATCH 2/3] fix s3 is always set to true if you make an error like invalid cron --- app/Livewire/Project/Database/CreateScheduledBackup.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Project/Database/CreateScheduledBackup.php b/app/Livewire/Project/Database/CreateScheduledBackup.php index e7bb451f6..272026797 100644 --- a/app/Livewire/Project/Database/CreateScheduledBackup.php +++ b/app/Livewire/Project/Database/CreateScheduledBackup.php @@ -49,6 +49,7 @@ class CreateScheduledBackup extends Component return; } + $payload = [ 'enabled' => true, 'frequency' => $this->frequency, @@ -58,6 +59,7 @@ class CreateScheduledBackup extends Component 'database_type' => $this->database->getMorphClass(), 'team_id' => currentTeam()->id, ]; + if ($this->database->type() === 'standalone-postgresql') { $payload['databases_to_backup'] = $this->database->postgres_db; } elseif ($this->database->type() === 'standalone-mysql') { @@ -72,11 +74,11 @@ class CreateScheduledBackup extends Component } else { $this->dispatch('refreshScheduledBackups'); } + + $this->frequency = ''; + } catch (\Throwable $e) { return handleError($e, $this); - } finally { - $this->frequency = ''; - $this->saveToS3 = true; } } } From 4cc4e28f297cff71470ced82260095db404b35cf Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:27:06 +0100 Subject: [PATCH 3/3] fix clear frequency on exit and error --- app/Livewire/Project/Database/CreateScheduledBackup.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Project/Database/CreateScheduledBackup.php b/app/Livewire/Project/Database/CreateScheduledBackup.php index 272026797..01108c290 100644 --- a/app/Livewire/Project/Database/CreateScheduledBackup.php +++ b/app/Livewire/Project/Database/CreateScheduledBackup.php @@ -75,10 +75,10 @@ class CreateScheduledBackup extends Component $this->dispatch('refreshScheduledBackups'); } - $this->frequency = ''; - } catch (\Throwable $e) { return handleError($e, $this); + } finally { + $this->frequency = ''; } } }