Skip to content
Advertisement

Update table structure without rollback in Laravel 5.1

I am beginner in Laravel. I use migrate to create tables in a database, but I don’t want to migrate:rollback to update my table.

I want to apply changes in my old database without loosing current data.

Old migration

JavaScript

New migration

JavaScript

Advertisement

Answer

As far as I know, this is not possible and not the intention of migrations. I think there are two options to solve this:

  1. If you aren’t in production, you can change the migration script and add the additional column manually using mysql:

    JavaScript
  2. If you need to update a productive database, you should add a second migration script only adding the additional column, e.g.:

    JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement