Pretty much just what the title says; I need to change a column name as part of a migration, can that be done and if so, how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Laravel 3
Yes it can be done, but only with raw queries. Some DBMS don’t support the changing of column names so it was decided to not implement such functionality since for some DBMS it would fail.
So don’t forget that you can leverage raw queries using
DB::raw()within migrations. You can change your column names that way.Laravel 4
In Laravel 4.1 you must add
doctrine/dbalas a dependency incomposer.json.Once you’ve run
composer updateyou can now use therenameColumnmethod.This will rename the
locationcolumn toaddress.