From your description, I assume the column is ->nullable()?
The only thing I can suggest is to check the config in tinker `config('database') to ensure this setting is in place.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have migration where I add foreign key to threads table (https://github.com/keizah7/forum/commit/e1aa1b31555c9469091be178e23f5746c377c080#diff-873a697d9df8d6d454c40acbb165080e)
Problem is that in phpunit test sqlite don't set foreign key null on delete.
1) Tests\Feature\BestReplyTest::if_a_best_reply_is_deleted_then_the_thread_is_properly_updated_to_reflect_that
Failed asserting that '1' is null.
For temporary solution I do it manually - I am using model static::deleted and then test is passing.
Where is the problem?
Jeffrey covered this topic in https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/82
but his solution doesn't help me. I'm using Laravel 7.3 and foreign_key_constraints is true by default.
Please or to participate in this conversation.