1

I have already created a migration file and tables have been created in database. Now, i want to add new column to the existing migration file. What I am doing is, I opened the migration file and added column names in up() function, after adding them, then i run command

php artisan migrate

The new columns did'nt get generated, instead i received an error. enter image description here

How can I add new columns to existing table?

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
TS.developer
  • 117
  • 2
  • 12
  • Possible duplicate of [Add a new column to existing table in a migration](https://stackoverflow.com/questions/16791613/add-a-new-column-to-existing-table-in-a-migration) – LuckyStarr Dec 14 '17 at 10:08
  • You don't modify migration files that have already been run; you create a new migration file purely to add the new column – Mark Baker Dec 14 '17 at 10:17
  • Okay! and for this first i'll have to delete that particular migration file and how? – TS.developer Dec 14 '17 at 10:33
  • Roll your version control back to the previous version of that migration file – Mark Baker Dec 14 '17 at 12:33

1 Answers1

0

You need to create new migration like below;

php artisan make:migration add_new_column_to_xtable_table --table="xtable"

then open your migraiton and add your new column here.

Then type "php artisan migrate" on console