首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MongoDB\Exception\InvalidArgumentException

MongoDB\Exception\InvalidArgumentException
EN

Stack Overflow用户
提问于 2021-08-31 07:14:32
回答 1查看 98关注 0票数 0

在laravel中运行迁移时出现此错误。我重新检查了模式中的数据类型是否为字符串。

正如您在模式中看到的那样,数据类型是一个字符串,但仍然得到这个错误。有什么解决方案吗?

代码语言:javascript
复制
MongoDB\Exception\InvalidArgumentException

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

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

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
    MongoDB\Model\IndexInput::__construct([])

迁移停止的地方

代码语言:javascript
复制
public function up()
{
    Schema::create('personal_access_tokens', function (Blueprint $table) {
        $table->morphs('tokenable');
        $table->index('name');
        $table->unique('token', 64);
        $table->text('abilities')->nullable();
        $table->timestamp('last_used_at')->nullable();
        $table->timestamps();
    });
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-31 09:31:06

您的问题是更改了Laravel Sanctum migration的实际实现。

$table->unique()期望第一个参数是列的name,第二个参数(可选)是唯一索引的name,但最初的实现使用$table->string('name', 64)->unique();,因此第一个参数是列name,而第二个参数是列的size,所以它与名称不同……

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68994349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档