DEV Community

Krixnaas
Krixnaas

Posted on

Laravel Migration Add Column After

php artisan make:migration update_users_table --table=users

If update file already exist
php artisan make:migration add_phone_number_to_users_table --table=users

/**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->text('phone_number')->nullable()->after('address');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('phone_number');
        });
    }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)