<?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::create('income_tax_brackets', function (Blueprint $table) {
            $table->id();
            $table->unsignedSmallInteger('tax_year')->comment('적용 연도 (예: 2024)');
            $table->unsignedInteger('salary_from')->comment('구간 하한 (천원 단위)');
            $table->unsignedInteger('salary_to')->comment('구간 상한 (천원 단위)');
            $table->unsignedTinyInteger('family_count')->comment('공제대상가족수 (1~11)');
            $table->unsignedInteger('tax_amount')->comment('세액 (원)');
            $table->timestamps();

            $table->index(['tax_year', 'salary_from', 'salary_to', 'family_count'], 'itb_lookup_idx');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('income_tax_brackets');
    }
};
