<?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
    {
        Schema::table('work_orders', function (Blueprint $table) {
            $table->unsignedTinyInteger('priority')->default(5)->after('status')
                ->comment('우선순위: 1(긴급)~9(낮음), 기본값 5(일반)');
            $table->index(['tenant_id', 'priority'], 'idx_work_orders_tenant_priority');
        });
    }

    public function down(): void
    {
        Schema::table('work_orders', function (Blueprint $table) {
            $table->dropIndex('idx_work_orders_tenant_priority');
            $table->dropColumn('priority');
        });
    }
};
