我有自定义迁移:
代码:
// 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();
});
当我运行此迁移文件时,会收到错误消息:
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table taxisms。#sql-1cc0_65c(errno: 150 "Foreign key constraint is wrongly forms") (SQL: alter table clientsadd constraint clients_group_id_foreignforeign key ( group_id) references groups( id) on delete cascade)
我的迁移代码哪里有错误?
守着一只汪