Laravel迁移连接表FK索引中是否存在错误?

Laravel迁移连接表FK索引中是否存在错误?,laravel,indexing,mariadb,foreign-keys,junction-table,Laravel,Indexing,Mariadb,Foreign Keys,Junction Table,我正在使用: Laravel框架8.21.0 10.4.14-10 对于任意两个表之间的连接表,以上述为例(在表用户和角色之间),创建连接表时不使用其中一个外键索引 public function up() { Schema::create('user_role', function (Blueprint $table) { $table->unsignedBigInteger('user_id'); $table->foreign('us

我正在使用:

  • Laravel框架8.21.0
  • 10.4.14-10
对于任意两个表之间的连接表,以上述为例(在表
用户
角色
之间),创建连接表时不使用其中一个外键索引

public function up()
{
    Schema::create('user_role', function (Blueprint $table) {
        $table->unsignedBigInteger('user_id');
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

        $table->unsignedBigInteger('role_id');
        $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');

        $table->unique(['user_id', 'role_id']);
    });
}
创建的索引是:

  • user\u role\u user\u id\u role\u id\u unique
  • user\u role\u role\u id\u foreign
缺少预期的
用户\u角色\u用户\u id\u外部

查询索引的
信息\u架构

SELECT i.name AS `Index`,
   GROUP_CONCAT(f.name ORDER BY f.pos) AS `Columns`
FROM information_schema.innodb_sys_tables t 
JOIN information_schema.innodb_sys_indexes i USING (table_id) 
JOIN information_schema.innodb_sys_fields f USING (index_id)
WHERE t.name = '******/user_role'
GROUP BY 1
我得到这个结果:

指数 柱
user\u role\u role\u id\u foreign
role\u id
user\u role\u user\u id\u role\u id\u unique
用户id
角色id