【发布时间】:2020-09-14 09:15:26
【问题描述】:
迁移运行时出现严重错误
(errno: 150 "外键约束格式不正确")
主键和外键的所有字段都具有相同的数据主键
它们都是无符号大整数
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email',100)->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->integer('rank');
$table->rememberToken();
$table->timestamps();
});
Schema::create('products', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
【问题讨论】:
标签: mysql laravel migration laravel-7