david19
2 months ago
184
4
Laravel

Rename Database Column

Posted 2 months ago by david19

Hello Team. I have a relation table "categories" with a column ForeignKey"category_id". It works all fine. But now i will change the name. "category_id" --> "parent_id". I deleted the table, and i made a new migration. Now the database is correct and shows "parent_id". I changed all my files and replace "category_id" with "parent_id". All is clean now. But laravel give me a error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categories.category_id' in 'where clause' (SQL: select * from `categories` where `categories`.`category_id` in (1)) 

Laravel search for the category_id column, but i changed all files to parent_id. How i can fix this? Should i delete the model, and remake them??

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