<?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('classes', function (Blueprint $table) {
            $table->id();
            $table->branchColumn();
            $table->string('name', 80);                 // e.g. "Grade 1", "Class 10"
            $table->unsignedSmallInteger('level')->default(0); // ordering / promotion sequence
            $table->boolean('is_active')->default(true)->index();
            $table->auditColumns();
            $table->timestamps();
            $table->softDeletes();

            $table->unique(['branch_id', 'name']);
        });
    }

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