rename schemalessAttrributes

This commit is contained in:
Andras Bacsai 2023-05-30 09:52:58 +02:00
parent bdb19dae89
commit 108c790cf4
8 changed files with 17 additions and 17 deletions

View File

@ -38,7 +38,7 @@ class Deploy extends Component
queue_application_deployment( queue_application_deployment(
application: $this->application, application: $this->application,
metadata: [ extra_attributes: [
'deployment_uuid' => $this->deployment_uuid, 'deployment_uuid' => $this->deployment_uuid,
'application_uuid' => $this->application->uuid, 'application_uuid' => $this->application->uuid,
'force_rebuild' => $force, 'force_rebuild' => $force,

View File

@ -24,7 +24,7 @@ class Rollback extends Component
queue_application_deployment( queue_application_deployment(
application: $this->application, application: $this->application,
metadata: [ extra_attributes: [
'deployment_uuid' => $deployment_uuid, 'deployment_uuid' => $deployment_uuid,
'application_uuid' => $this->application->uuid, 'application_uuid' => $this->application->uuid,
'force_rebuild' => false, 'force_rebuild' => false,

View File

@ -229,9 +229,9 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
if ($next_found) { if ($next_found) {
dispatch(new ApplicationDeploymentJob( dispatch(new ApplicationDeploymentJob(
application_deployment_queue_id: $next_found->id, application_deployment_queue_id: $next_found->id,
deployment_uuid: $next_found->metadata['deployment_uuid'], deployment_uuid: $next_found->extra_attributes['deployment_uuid'],
application_uuid: $next_found->metadata['application_uuid'], application_uuid: $next_found->extra_attributes['application_uuid'],
force_rebuild: $next_found->metadata['force_rebuild'], force_rebuild: $next_found->extra_attributes['force_rebuild'],
)); ));
} }
} }

View File

@ -11,14 +11,14 @@ class ApplicationDeploymentQueue extends Model
protected $fillable = [ protected $fillable = [
'application_id', 'application_id',
'status', 'status',
'metadata', 'extra_attributes',
]; ];
public $casts = [ public $casts = [
'metadata' => SchemalessAttributes::class, 'extra_attributes' => SchemalessAttributes::class,
]; ];
public function scopeWithExtraAttributes(): Builder public function scopeWithExtraAttributes(): Builder
{ {
return $this->metadata->modelScope(); return $this->extra_attributes->modelScope();
} }
} }

View File

@ -4,11 +4,11 @@ use App\Jobs\ApplicationDeploymentJob;
use App\Models\Application; use App\Models\Application;
use App\Models\ApplicationDeploymentQueue; use App\Models\ApplicationDeploymentQueue;
function queue_application_deployment(Application $application, $metadata) function queue_application_deployment(Application $application, $extra_attributes)
{ {
$deployment = ApplicationDeploymentQueue::create([ $deployment = ApplicationDeploymentQueue::create([
'application_id' => $application->id, 'application_id' => $application->id,
'metadata' => $metadata, 'extra_attributes' => $extra_attributes,
]); ]);
$queued_deployments = ApplicationDeploymentQueue::where('application_id', $application->id)->where('status', 'queued')->get()->sortByDesc('created_at'); $queued_deployments = ApplicationDeploymentQueue::where('application_id', $application->id)->where('status', 'queued')->get()->sortByDesc('created_at');
$running_deployments = ApplicationDeploymentQueue::where('application_id', $application->id)->where('status', 'in_progress')->get()->sortByDesc('created_at'); $running_deployments = ApplicationDeploymentQueue::where('application_id', $application->id)->where('status', 'in_progress')->get()->sortByDesc('created_at');
@ -24,9 +24,9 @@ function queue_application_deployment(Application $application, $metadata)
} }
dispatch(new ApplicationDeploymentJob( dispatch(new ApplicationDeploymentJob(
application_deployment_queue_id: $deployment->id, application_deployment_queue_id: $deployment->id,
deployment_uuid: $metadata['deployment_uuid'], deployment_uuid: $extra_attributes['deployment_uuid'],
application_uuid: $metadata['application_uuid'], application_uuid: $extra_attributes['application_uuid'],
force_rebuild: $metadata['force_rebuild'], force_rebuild: $extra_attributes['force_rebuild'],
commit: $metadata['commit'] ?? null, commit: $extra_attributes['commit'] ?? null,
)); ));
} }

View File

@ -41,7 +41,7 @@ return new class extends Migration
$table->string('base_directory')->default('/'); $table->string('base_directory')->default('/');
$table->string('publish_directory')->nullable(); $table->string('publish_directory')->nullable();
$table->schemalessAttributes('previews'); $table->schemalessAttributes('extra_attributes');
$table->string('health_check_path')->default('/'); $table->string('health_check_path')->default('/');
$table->string('health_check_port')->nullable(); $table->string('health_check_port')->nullable();

View File

@ -15,7 +15,7 @@ return new class extends Migration
$table->id(); $table->id();
$table->string('application_id'); $table->string('application_id');
$table->integer('pull_request_id')->default(0); $table->integer('pull_request_id')->default(0);
$table->schemalessAttributes('metadata'); $table->schemalessAttributes('extra_attributes');
$table->string('status')->default('queued'); $table->string('status')->default('queued');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -13,7 +13,7 @@
'border-error hover:bg-error' => $deployment->status === 'error', 'border-error hover:bg-error' => $deployment->status === 'error',
'border-success hover:bg-success' => $deployment->status === 'finished', 'border-success hover:bg-success' => $deployment->status === 'finished',
]) @if ($deployment->status !== 'cancelled by system' && $deployment->status !== 'queued') ]) @if ($deployment->status !== 'cancelled by system' && $deployment->status !== 'queued')
href="{{ $current_url . '/' . $deployment->metadata['deployment_uuid'] }}" href="{{ $current_url . '/' . $deployment->extra_attributes['deployment_uuid'] }}"
@endif @endif
class="hover:no-underline"> class="hover:no-underline">
<div class="flex flex-col justify-start"> <div class="flex flex-col justify-start">