<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * admin_pm_issues 테이블에 일정 관련 필드 추가
     */
    public function up(): void
    {
        Schema::table('admin_pm_issues', function (Blueprint $table) {
            $table->date('start_date')->nullable()->after('status')->comment('시작일');
            $table->date('due_date')->nullable()->after('start_date')->comment('마감일');
            $table->unsignedInteger('estimated_hours')->nullable()->after('due_date')->comment('예상 시간(시)');

            // 인덱스
            $table->index('due_date', 'idx_admin_pm_issues_due_date');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('admin_pm_issues', function (Blueprint $table) {
            $table->dropIndex('idx_admin_pm_issues_due_date');
            $table->dropColumn(['start_date', 'due_date', 'estimated_hours']);
        });
    }
};
