Add Column After A Column In Laravel Migration

Add Column After A Column In Laravel Migration

Add Column After A Column In Laravel Migration

In this post, we will give you information about Add Column After A Column In Laravel Migration. Here we will give you detail about Add Column After A Column In Laravel Migration And how to use it also give you a demo for it if it is necessary.

By adding new tables and columns. Laravel Migrations provide you the ability to manage the structure of your database. The Laravel Migrations act as database version control.

In Add Column After A Column In Laravel Migration tutorial, We’ll look at how to add one column at a time to the Laravel migration. It’s probable that you’ll need to add a new field to the database table once a project is completed. Creating a new migration in Laravel will make it straightforward to do so in that instance.

To make understanding easier, you should put that column after the relevant one. So let’s look at the process.

Add Column After A Column In Laravel Migration

Laravel 10.0  introduces a new after method on the Blueprint migration instance which allows you to add multiple new columns after an existing column at the same time:

Schema::table('users', function ($table) {
     $table->after('password', function ($table) {
        $table->string('address_line1');
        $table->string('address_line2');
        $table->string('city');
     });
});

Thank you for reading Add Column After A Column In Laravel Migration article.Hope this code and post will helped you for implement Add Column After A Column In Laravel Migration. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US