(errno: 150 “Foreign key constraint is incorrectly formed “)”)

I am trying to create scheduleUser migration but this error is popping out although I am using the same standards I’ve been taught. I created another schema it gave me the same error. I made sure the relationships is written in a correct way still having the same error. I am using Laravel v.12.

This is the scheduleUser migration:

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('scheduelusers', function (Blueprint $table) {
            
            $table->id();
            // $table->unsignedBigInteger('studentId')-> primary()->nullable() -> from(100000);
            $table -> string('firstName');
            $table -> string ('middleName');
            $table -> string ('lastName');
            $table -> string ('email')-> unique();
            $table -> string ('password');
            $table -> string ('phone')-> unique();
            $table -> foreignId('role_id')->constrained();
            
            $table->timestamps();
        });
    }

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

This is the function I am using in scheduleusers migration for the relationship:

    public function role()
    {
        return $this->belongsTo(Role::class);
    }
    
}

This is the role migration:

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->id();
            $table -> string('role');
            $table->timestamps();
        });
    }

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

This is the function in role model for the relationship:

    public function scheduleusers()
    {
        return $this->hasMany(ScheduleUser::class);
    }
}