refactor: move buildpack cleanup logic to model lifecycle hooks

Move buildpack switching cleanup from Livewire component to Application model's boot lifecycle. This improves separation of concerns and ensures cleanup happens consistently regardless of how the buildpack change is triggered. Also clears Dockerfile-specific data when switching away from dockerfile buildpack.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-11-18 09:46:04 +01:00
parent 4592d19ed3
commit 36d2c02498
5 changed files with 379 additions and 14 deletions

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Clear dockerfile fields for applications not using dockerfile buildpack
DB::table('applications')
->where('build_pack', '!=', 'dockerfile')
->update([
'dockerfile' => null,
'dockerfile_location' => null,
'dockerfile_target_build' => null,
'custom_healthcheck_found' => false,
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// No rollback needed - we're cleaning up corrupt data
}
};