Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 6-MariaDB 10.1:Illumb\Database\QueryException:SQLSTATE[HY000]迁移错误_Php_Mysql_Laravel_Mariadb - Fatal编程技术网

Php Laravel 6-MariaDB 10.1:Illumb\Database\QueryException:SQLSTATE[HY000]迁移错误

Php Laravel 6-MariaDB 10.1:Illumb\Database\QueryException:SQLSTATE[HY000]迁移错误,php,mysql,laravel,mariadb,Php,Mysql,Laravel,Mariadb,我有自定义迁移: 代码: // Groups migration Schema::create('groups', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->boolean('status')->default(false); $table->timestamps(); }); // Clien

我有自定义迁移:

代码:

// Groups migration
Schema::create('groups', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('name');
    $table->boolean('status')->default(false);
    $table->timestamps();
});

// Clients migration
Schema::create('clients', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('fullname');
    $table->integer('phone');
    $table->date('birthday')->nullable();
    $table->boolean('can_get_congratulations')->default(false);
    $table->unsignedInteger('group_id')->default(null);
    $table->foreign('group_id')
          ->references('id')
          ->on('groups')
          ->onDelete('cascade');
    $table->boolean('status')->default(true);
    $table->timestamps();
});
运行此迁移文件时,会收到错误消息:

Illumb\Database\QueryException:SQLSTATE[HY000]:一般错误: 1005无法创建表
taxisms
\sql-1cc0\u 65c
(错误号:150“外部 键约束格式不正确”)(SQL:alter table
clients
add 约束
客户端\u组\u id\u外键
外键(
组\u id
) 删除级联上的引用
id


迁移代码中哪里有错误?

该列需要在两侧匹配。由于
groups.id
是一个无符号大整数,因此group\u id也需要是。改变

$table->unsignedInteger('group_id') 


这是
cascade
,不是
casecade
@aynber,因为我改为
cascade
,但也会出错。查看更新的问题您是否也可以显示您的
迁移?@aynber查看更新的问题如果我没记错,列定义需要在两侧匹配。由于
groups.id
是一个无符号大整数,
group\u id
也需要是一个无符号大整数。将
$table->unsignedInteger('group\u id')
更改为
$table->unsignedbiginger('group\u id')
$table->unsignedBigInteger('group_id')