gewode
7 months ago

SQLite Foreign Keys with Set Null on Delete not working for PHPUnit test

Posted 7 months ago by gewode

I have added a foreign keys constraint in migration file for posts table to the user_id column. So, on delete user, I want to set the user_id column to null. So, I added this.

$table->foreign('user_id')
                ->references('id')
                ->on('users')
                ->onDelete('set null');

It is working on the MySQL database. But not working on SQLite PHPUnit test. I have enabled foreign key constraints for SQLite, but still not working.

Please guide How can I make it work?

Please sign in or create an account to participate in this conversation.