I am trying to make a migration in my Laravel project, but i get the following error:
SQLSTATE: Syntax error or access violation: 1072 Key column ‘department_id’ doesn’t exist in table (SQL: alter table
I removed 1 line from my table.php file which i thought caused the error, and then it worked just fine. Could someone explain where my syntax is wrong in the following line?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
The error means that there is no
department_id column that references the foreign key, Because you should create column before creating a foreign key, I think your migration file should contains the following: