Skip to content
Advertisement

: SQLSTATE[HY000]: General error: 1364 Field

I got this error, when I added columns

JavaScript

on create_posts_table.php. I was creating UserSeederTable but it doesn’t work. And why can’t I create PostSeedertable now? Before the columns adding, there were no errors. Please help.

JavaScript
JavaScript

JavaScript
JavaScript

Advertisement

Answer

It’s telling you that user_id cannot be null and it’s currently null. This typically means user_id isn’t being filled by the factory.

You have 3 options:

  • Update your post factory to include user_id

OR

  • You can bypass this by changing the migration to allow user_id to be nullable.

OR

  • Setting a default value for user_id in the migration
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement