【发布时间】:2019-01-22 10:48:15
【问题描述】:
我想创建一个删除表的迁移。我像这样创建了迁移:
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
devicesdrop 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
【问题讨论】:
标签: php mysql laravel laravel-5.6