Tag

Add Column

Browsing

Today, We are going to learn Laravel Migration add new column to an existing table.  In the last Laravel Migration tutorial, We learn How to create the database table using Laravel Migrations. In this tutorial, We are going to learn How to add a new column to an existing table. Many times we need an extra column after the table has been created using Laravel migrations. Let’s see how we can manage migration files for adding the extra column to the database table.

Today, We are going to add the column for an image on the blog table. First, follow this tutorial for creating the blog table. After, creating the blog table let’s see how we can add the new column to existing blog table.

Laravel Migration add new column

First of all, We are going to create the migration file to add a new column to existing database table. Let’s follow the command for creating the migration.

Finally, We are ready with the new migration file. The new migration will generate into database/migrations directory. Let’s open the migration file and write the code to add an image column to an existing database table.

Finally, We are ready with the migration file. Now, let’s run the migration by following the command.

Finally, We add the new image column to a blog table. So, it’s too easy to add an extra column to an existing table using laravel migrations. Still, If you face any issue write the comment.