<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterUserTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        if (Schema::hasTable('users')) {
            if (!Schema::hasColumn('users', 'username')) {
                Schema::table('users', function (Blueprint $table) {
                    $table->string('username')->after('email');
                    $table->unique('username');
                });
            }
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        //
    }
}

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterUserTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        if (Schema::hasTable('users')) {
            if (!Schema::hasColumn('users', 'username')) {
                Schema::table('users', function (Blueprint $table) {
                    $table->string('username');

                    $table->unique('username');
                });
            }
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        //
    }
}

Remove after column for SQL lite compatibility
Remove after column for SQL lite compatibility
