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

44
routes/console.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
use App\Models\MigrationSchedule;
use App\Models\MigrationRun;
use App\Jobs\RunMigrationJob;
// Check for due migration schedules every minute
Schedule::call(function () {
$schedules = MigrationSchedule::where('is_active', true)
->where(function ($query) {
$query->whereNull('next_run_at')
->orWhere('next_run_at', '<=', now());
})
->get();
foreach ($schedules as $schedule) {
// Skip if there's already a running or pending migration
$existingRun = MigrationRun::where('schedule_id', $schedule->id)
->whereIn('status', ['pending', 'running'])
->latest()
->first();
if ($existingRun) {
continue; // Skip this schedule, migration already in progress
}
// Create migration run and dispatch job
$migrationRun = MigrationRun::create([
'schedule_id' => $schedule->id,
'status' => 'pending',
'total_tables' => count($schedule->tables),
]);
RunMigrationJob::dispatch($migrationRun)->onQueue('default');
}
})->name('check-migration-schedules')->everyMinute()->withoutOverlapping();
// Check for schema changes every hour
Schedule::command('schema:check-changes')
->hourly()
->withoutOverlapping()
->onOneServer();