<?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('job_grades', function (Blueprint $table) {
            $table->id();
            $table->string('name'); // e.g. "Grade 5 - Senior Officer"
            $table->enum('range_type', ['flat', 'percentage'])->default('flat');
            $table->foreignId('organisation_id')->constrained()->onDelete('cascade');
            // Salary Range - Flat Values
            $table->decimal('min_salary', 15, 2)->nullable();
            $table->decimal('mid_salary', 15, 2)->nullable();
            $table->decimal('max_salary', 15, 2)->nullable();

            // Salary Range - Percentage Values (of Gross)
            $table->decimal('min_percent', 5, 2)->nullable();
            $table->decimal('mid_percent', 5, 2)->nullable();
            $table->decimal('max_percent', 5, 2)->nullable();

            $table->text('notes')->nullable(); // optional description or comments
            $table->timestamps();
        });
    }

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