You cannot drop a foreign key on a SQLite database
You could try squashing the migrations so it effectively never exists
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am using Pest for testing and now I am having trouble related to the database. The trouble is I removed a foreign key from my table (the migration ran successfully). But when running the test cases related to this database change I get this error:
This database driver does not support dropping foreign keys.
Why is that? My local database did run this migration successfully. If I delete the migration file I get another error related to the user_id not being added when created a new wishlist.
So my question is basically, is there a way to clear the database used for testing?
Here is my migration file:
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('wishlists', function (Blueprint $table) {
$table->dropForeign(['user_id']);
$table->dropColumn('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('wishlists', function (Blueprint $table) {
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
};
You cannot drop a foreign key on a SQLite database
You could try squashing the migrations so it effectively never exists
Please or to participate in this conversation.