Php Laravel雄辩地迫使我的var成为主键

Php Laravel雄辩地迫使我的var成为主键,php,mysql,laravel,Php,Mysql,Laravel,我试图运行迁移来创建数据库,但我所做的所有更改最终都会在mysql级别出错。模型是User、Classedeusu(用户的类)和classxusu(关系nxm,类x用户) ClasseDusu(用户类)的定义 用户定义 Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $t

我试图运行迁移来创建数据库,但我所做的所有更改最终都会在mysql级别出错。模型是User、Classedeusu(用户的类)和classxusu(关系nxm,类x用户)

ClasseDusu(用户类)的定义

用户定义

    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
类xusu(n×m)的定义

在classxusu上,如果我将列
user\u id
定义为
$table->integer
,我在
classxusu
中得到一个MySql整数(11)有符号列(但在
users
表上,
$table->id
生成了一个整数(10)无符号列)。但是,如果我将其更改为除
$table->integer
(例如,
$table->integer('user_id',10)->unsigned()
),则该列将自动标识为主键,因此我在$table->primary(['classe',user_id')的下一行中出现错误


那么,如何解决这个问题呢?

这并不能解决问题,正如我已经提到的,当我将其更改为
$table->integer('user_id',10)->unsigned()
时,它被认为是导致下一行错误的主键。为了每个人的利益,请使用英语作为表(及其字段)的名称,并使用正确的命名约定。您使用的是哪种Laravel版本?正如我已经提到的,当我将其更改为
$table->integer('user_id',10)->unsigned()
时,它被认为是主键,会导致下一行的错误。为了所有人的利益,请使用英语对表(及其字段)进行命名,并使用正确的命名约定。你用的是什么样的拉维版本?
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
    Schema::create('classexusus', function (Blueprint $table) {
        $table->string('classe');
        $table->integer('user_id');
        $table->primary(['classe', 'user_id']);
        $table->foreign('classe')->references('classe')->on('classedeusus');
        $table->foreign('user_id')->references('id')->on('users');
    });