<?php

use App\Models\Department;
use App\Models\Dealer;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    public function up(): void
    {
        // Soft delete System Administration departments for all non-default dealers (one-time cleanup).
        Department::query()
            ->where('name', 'System Administration')
            ->whereHas('dealer', function ($query): void {
                $query->where('is_default', false);
            })
            ->delete();
    }

    public function down(): void
    {
        // No-op: deleted departments are not restored automatically.
    }
};

