私は移行をリフレッシュしようとしています。しかし、php artisan migrate:refresh
コマンドが機能していません。 それは次のエラーを示していますLaravel: 'dropForeign'メソッドを使用しても外部キーを削除できません
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'classes_userid_foreign'; check that column/key exists (SQL: alter table
classes
drop foreign keyclasses_userid_foreign
)[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'classes_userid_foreign'; check that column/key
exists
私もdropForeign
を使用しますが、その私のために働いていません。
私はこの問題を解決するためにどのようmigration
ファイル
public function up()
{
Schema::create('classes', function (Blueprint $table) {
$table->increments('id');
$table->integer('userId')->unsigned();
$table->string('title');
$table->string('name');
$table->string('code')->unique();
$table->integer('capacity')->unsigned();
$table->integer('tagId')->unsigned();
$table->foreign('userId')->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('classes', function (Blueprint $table) {
$table->dropForeign(['userId']);
});
Schema::drop('classes');
}
を示していますか?
表を確認しましたし、外部キーが存在することを確認しますか? – user3158900