Altering a migration
Migration workflows are one more thing that makes Laravel such a great framework for teams as well as the lone developer. In this recipe, we are going to show the proper way to change a migration.
Getting ready
Even a fresh install will get you started, we just need a migration and then we will alter it. In this case, we are going to alter the users
table.
How to do it....
Follow these steps to alter the users
table:
- Inside Vagrant, run your migration if you have not already. We talked about setting up Vagrant in Chapter 1, Setting Up and Installing Laravel.
- Then type:
>php artisan make:migration alter_users_table_add_twitter_name_field
- Now you will have the file in your
database/migrations
folder—edit that so it looks like the following: - Then we need to modify it to add the actual logic to alter the table
users
. In this case by adding a field: - Then run the migration:
>php artisan migrate
- That's it, you now have a new field to save twitter names too!