<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * Creates the staff_achievements table to store achievements
     * and accomplishments of staff members during their employment.
     *
     * @return void
     */
    public function up(): void
    {
        Schema::create('staff_achievements', function (Blueprint $table) {
            // Primary key
            $table->id();

            // Foreign key to staff histories
            $table->foreignId('staff_history_id')
                ->constrained('staff_histories')
                ->onDelete('cascade');

            // Achievement details
            $table->text('achievement_description');
            $table->date('achievement_date');

            // Timestamps
            $table->timestamps();

            // Indexes for performance
            $table->index('staff_history_id');
            $table->index('achievement_date');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(): void
    {
        Schema::dropIfExists('staff_achievements');
    }
};
