Laravel Migration Add Column After

krixnaas

Krixnaas

Posted on June 16, 2022

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
💖 💪 🙅 🚩
krixnaas
Krixnaas

Posted on June 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related