fix(restarts): reset legacy restart limits during migration

Normalize existing resources with the old restart limit defaults so restart limits remain opt-in.
This commit is contained in:
Andras Bacsai
2026-09-15 13:28:50 +02:00
parent ab30f95ad9
commit 113a2f229d
2 changed files with 21 additions and 1 deletions
@@ -2,10 +2,13 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public $withinTransaction = false;
/**
* Run the migrations.
*/
@@ -15,6 +18,18 @@ return new class extends Migration
Schema::table($tableName, function (Blueprint $table) {
$table->integer('max_restart_count')->default(0)->change();
});
DB::table($tableName)
->select('id')
->where('max_restart_count', 10)
->chunkById(5000, function ($resources) use ($tableName): void {
DB::table($tableName)
->whereIn('id', $resources->pluck('id'))
->update([
'max_restart_count' => 0,
'restart_limit_reached' => false,
]);
});
}
}
@@ -220,7 +220,12 @@ it('makes restart limits opt in for new application resources', function () {
expect($migration)
->toContain("['applications', 'application_previews', 'service_applications']")
->toContain("integer('max_restart_count')->default(0)->change()")
->not->toContain('->update(');
->toContain('public $withinTransaction = false;')
->toContain("->where('max_restart_count', 10)")
->toContain('->chunkById(5000')
->toContain("->whereIn('id', \$resources->pluck('id'))")
->toContain("'max_restart_count' => 0")
->toContain("'restart_limit_reached' => false");
$applicationSettings = file_get_contents(app_path('Livewire/Project/Application/Advanced.php'));
$serviceSettings = file_get_contents(app_path('Livewire/Project/Service/Index.php'));