An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: rollback feature
Andras Bacsaie2cd7fe17ec4
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 2584df48bd..5c8827085b 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -56,7 +56,7 @@ class Handler extends ExceptionHandler{$this->reportable(function (Throwable $e) {if (isDev()) {- // return;+ return;}if ($e instanceof RuntimeException) {return;diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex ced01c43c1..6bb8eadc7e 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -49,6 +49,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncryptedprivate string $deployment_uuid;private int $pull_request_id;private string $commit;+ private bool $rollback;private bool $force_rebuild;private bool $restart_only;@@ -117,6 +118,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted$this->deployment_uuid = $this->application_deployment_queue->deployment_uuid;$this->pull_request_id = $this->application_deployment_queue->pull_request_id;$this->commit = $this->application_deployment_queue->commit;+ $this->rollback = $this->application_deployment_queue->rollback;$this->force_rebuild = $this->application_deployment_queue->force_rebuild;$this->restart_only = $this->application_deployment_queue->restart_only;$this->only_this_server = $this->application_deployment_queue->only_this_server;@@ -1070,7 +1072,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted],);}- if ($this->saved_outputs->get('git_commit_sha')) {+ if ($this->saved_outputs->get('git_commit_sha') && !$this->rollback) {$this->commit = $this->saved_outputs->get('git_commit_sha')->before("\t");}}diff --git a/app/Livewire/Project/Application/Rollback.php b/app/Livewire/Project/Application/Rollback.phpindex cd778f979e..f926b8e128 100644--- a/app/Livewire/Project/Application/Rollback.php+++ b/app/Livewire/Project/Application/Rollback.php@@ -26,6 +26,7 @@ class Rollback extends Componentapplication: $this->application,deployment_uuid: $deployment_uuid,commit: $commit,+ rollback: true,force_rebuild: false,);return redirect()->route('project.application.deployment.show', [diff --git a/bootstrap/helpers/applications.php b/bootstrap/helpers/applications.phpindex 8d810da0f5..c0aaf4abfd 100644--- a/bootstrap/helpers/applications.php+++ b/bootstrap/helpers/applications.php@@ -9,7 +9,7 @@ use App\Models\StandaloneDocker;use Illuminate\Support\Collection;use Spatie\Url\Url;-function queue_application_deployment(Application $application, string $deployment_uuid, int | null $pull_request_id = 0, string $commit = 'HEAD', bool $force_rebuild = false, bool $is_webhook = false, bool $restart_only = false, ?string $git_type = null, bool $no_questions_asked = false, Server $server = null, StandaloneDocker $destination = null, bool $only_this_server = false)+function queue_application_deployment(Application $application, string $deployment_uuid, int | null $pull_request_id = 0, string $commit = 'HEAD', bool $force_rebuild = false, bool $is_webhook = false, bool $restart_only = false, ?string $git_type = null, bool $no_questions_asked = false, Server $server = null, StandaloneDocker $destination = null, bool $only_this_server = false, bool $rollback = false){$application_id = $application->id;$deployment_link = Url::fromString($application->link() . "/deployment/{$deployment_uuid}");@@ -38,6 +38,7 @@ function queue_application_deployment(Application $application, string $deployme'is_webhook' => $is_webhook,'restart_only' => $restart_only,'commit' => $commit,+ 'rollback' => $rollback,'git_type' => $git_type,'only_this_server' => $only_this_server]);diff --git a/database/migrations/2024_04_17_132541_add_rollback_queues.php b/database/migrations/2024_04_17_132541_add_rollback_queues.phpnew file mode 100644index 0000000000..27865cf0db--- /dev/null+++ b/database/migrations/2024_04_17_132541_add_rollback_queues.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('application_deployment_queues', function (Blueprint $table) {+ $table->boolean('rollback')->default(false);+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('application_deployment_queues', function (Blueprint $table) {+ $table->dropColumn('rollback');+ });+ }+};