mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-24 23:40:16 -05:00
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:
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user