Closed likeabas closed 5 months ago
A quick solution is to create a migration to just drop the foreign key on the imports table, but I'm reporting this issue for others who might run into it and because maybe there's a better solution. I think this should be a low priority issue.
I have solved this in my project with the following migration, changing the foreign key to the set auth provider table, in my case 'admins':
Create a migration:
php artisan make:migration change_imports_foreign_key_to_admins_table
The migration file I used, replace admins
with your table name
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Drop the old foreign key
Schema::table('imports', function (Blueprint $table) {
$table->dropForeign(['user_id']);
});
// Add the new foreign key
Schema::table('imports', function (Blueprint $table) {
$table->foreign('user_id')->references('id')->on('admins')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Drop the new foreign key
Schema::table('imports', function (Blueprint $table) {
$table->dropForeign(['user_id']);
});
// Add the old foreign key
Schema::table('imports', function (Blueprint $table) {
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
};
The migration is published, so you can customize it without even creating a new migration. I don't think there is anything for us to fix here
Package
filament/filament
Package Version
v3.2.79
Laravel Version
v11.7.0
Livewire Version
v3.4.12
PHP Version
8.2
Problem description
When you change the users provider table to another table than users, you get a foreign key constraint failure on the
imports
table, because theimports_user_id_foreign
refers to theusers
table.Expected behavior
No foreign key constraint to the user table in this case.
Steps to reproduce
users
.config/auth.php
and in your admin panel using these steps in the docs.users
tableReproduction repository
https://github.com
Relevant log output
Donate 💰 to fund this issue