<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        // PRC-351 — "global default" SLA plan. A plan flagged is_global is
        // used when a ticket's department has no own sla_plan_id, before
        // falling back to the settings defaults. Department linkage stays on
        // ticket_departments.sla_plan_id (Option B — no schema conflict).
        Schema::table('sla_plans', function (Blueprint $table) {
            $table->boolean('is_global')->default(false)->after('is_active');
        });
    }

    public function down(): void
    {
        Schema::table('sla_plans', function (Blueprint $table) {
            $table->dropColumn('is_global');
        });
    }
};
