Getting this error while running migration in laravel. I Have rechecked my data type in the schema is a string.

As you can see in the schema the datatype is a string but still getting this error. Any solutions???


Expected "name" option to have type "string" but found "int"

at D:\CRUD\CRUD\vendor\mongodb\mongodb\src\Exception\InvalidArgumentException.php:60
   57▕             $expectedType = $typeString;
   58▕         }
➜  60▕         return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, get_debug_type($value)));
   61▕     }
   62▕ }

1   D:\CRUD\CRUD\vendor\mongodb\mongodb\src\Model\IndexInput.php:71
    MongoDB\Exception\InvalidArgumentException::invalidType(""name" option", "string")

2   D:\CRUD\CRUD\vendor\mongodb\mongodb\src\Operation\CreateIndexes.php:118

Migration where it stopped

public function up()
    Schema::create('personal_access_tokens', function (Blueprint $table) {
        $table->unique('token', 64);


Your problem is that you have changed the actual implementation of Laravel Sanctum migration.

$table->unique() expects first parameter to be the column’s name and second (optional) to be the unique index’s name, but the original implementation uses $table->string('name', 64)->unique();, so the first one is the column name, but the second one is the column’s size, so that is not the same as a name…

Answered By – matiaslauriti

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published