-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log Update results to database (#22)
- Loading branch information
1 parent
ecdd86c
commit 1089b02
Showing
6 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
class UpdateException extends \Exception | ||
{ | ||
public readonly string $updateStep; | ||
|
||
public function __construct( | ||
string $updateStep, | ||
string $message, | ||
int $code = 0, | ||
?\Throwable $previous = null | ||
) { | ||
$this->updateStep = $updateStep; | ||
|
||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
public function getStep(): string | ||
{ | ||
return $this->updateStep; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Update extends Model | ||
{ | ||
protected $fillable = [ | ||
'old_version', | ||
'new_version', | ||
'result', | ||
'failed_step', | ||
'failed_message', | ||
'failed_trace' | ||
]; | ||
|
||
protected function casts(): array | ||
{ | ||
return [ | ||
'result' => 'bool' | ||
]; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
database/migrations/2025_01_18_114039_add_updates_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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::create('updates', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('site_id'); | ||
$table->string('old_version'); | ||
$table->string('new_version'); | ||
$table->boolean('result'); | ||
$table->string('failed_step')->nullable(); | ||
$table->text('failed_message')->nullable(); | ||
$table->text('failed_trace')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('updates'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters