<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * Changes entity_id from bigint to string (char(36)) to support UUID
     * This is needed because attendance.id is now UUID
     */
    public function up(): void
    {
        // Change entity_id from bigint to char(36) to support UUID
        // Use raw SQL because Laravel doesn't support changing column type easily
        DB::statement('ALTER TABLE activity_records MODIFY entity_id VARCHAR(36) NULL');
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Note: This will fail if there are UUID values in entity_id
        // Only safe if all values are numeric
        DB::statement('ALTER TABLE activity_records MODIFY entity_id BIGINT UNSIGNED NULL');
    }
};
