first commit

This commit is contained in:
brusnitsyn
2026-03-23 00:51:38 +09:00
commit 07854e0a9d
110 changed files with 19528 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class MigrationRun extends Model
{
use HasFactory;
protected $fillable = [
'schedule_id',
'status',
'total_tables',
'processed_tables',
'total_rows',
'migrated_rows',
'failed_rows',
'error_message',
'logs',
'started_at',
'completed_at',
];
protected $casts = [
'logs' => 'array',
'total_tables' => 'integer',
'processed_tables' => 'integer',
'total_rows' => 'integer',
'migrated_rows' => 'integer',
'failed_rows' => 'integer',
'started_at' => 'datetime',
'completed_at' => 'datetime',
];
public function schedule(): BelongsTo
{
return $this->belongsTo(MigrationSchedule::class, 'schedule_id');
}
public function getProgressAttribute(): float
{
if ($this->total_tables === 0) {
return 0;
}
return round(($this->processed_tables / $this->total_tables) * 100, 2);
}
public function getDurationAttribute(): ?string
{
if (!$this->started_at) {
return null;
}
$end = $this->completed_at ?? now();
$duration = $this->started_at->diff($end);
return $duration->format('%H:%I:%S');
}
}