<?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('tahun_ajaran', function (Blueprint $table) {
            if (!Schema::hasColumn('tahun_ajaran', 'bulan_mulai_spp')) {
                // 1 = Januari, 12 = Desember. Default Juli (awal tahun ajaran umum)
                $table->unsignedTinyInteger('bulan_mulai_spp')->default(7)->after('status');
            }
            if (!Schema::hasColumn('tahun_ajaran', 'bulan_selesai_spp')) {
                // Default Juni (akhir tahun ajaran umum)
                $table->unsignedTinyInteger('bulan_selesai_spp')->default(6)->after('bulan_mulai_spp');
            }
        });
    }

    public function down(): void
    {
        Schema::table('tahun_ajaran', function (Blueprint $table) {
            $table->dropColumn(['bulan_mulai_spp', 'bulan_selesai_spp']);
        });
    }
};
