我想创建一个迁移,以删除一张表。我创建了以下迁移:
Schema::table('devices', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('client_id')->nullable();
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
});
现在我尝试这样删除它:
Schema::table('devices', function (Blueprint $table) {
$table->dropForeign('devices_client_id_foreign');
$table->drop('devices');
});
但我收到以下错误信息:
In Connection.php line 664: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'devices_client_id_foreign'; check that column/key exists (SQL:
alter table
devices
drop foreign keydevices_client_id_foreign
)
In PDOStatement.php line 144: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'devices_client_id_foreign'; check that column/key exists In PDOStatement.php line 142: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'devices_client_id_foreign'; check that column/key exists