Join WhatsApp ChannelJoin Now

Migration Add Column After Column in laravel

Hi Dev,

Today, i we will show you Migration Add Column After Column in laravel. This article will give you simple example of Migration Add Column After Column in laravel. you will Migration Add Column After Column in laravel. In this article, we will implement a Migration Add Column After Column in laravel.

So, let’s follow few steps to create example of Migration Add Column After Column in laravel.

Migration Command

php artisan make:migration add_new_columns_posts

Example: using after()

database/migrations/2023_01_16_134448_add_new_columns_posts.php

<?php
  
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
  
class CreateItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('posts', function($table)
        {
            $table->tinyInteger('status')->after('body');
        });
    }
 
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        	
    }
}

Run Migration

php artisan migrate

I hope it will assist you…

Recommended Posts