Support the ongoing development of Laravel.io →
Database Laravel
Last updated 2 years ago.
0

First Create Migration for add new fields

php artisan make:migration add_description_to_demo

Then just set the migration up with the details like which col you like to add

Schema::table('demo', function ($table) {
    $table->text('description');
});

Then you can just migrate it:

php artisan migrate

This will allow you to add a column without resetting or rolling back your tables

Last updated 6 years ago.
0

Thanks Pradeep, will give a try.

0

@Khushbu Patel You should try this way:


php artisan make:migration update_demo_table

<?php

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

class UpdateDemoTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('demo', function (Blueprint $table) {
            $table->text('address')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('demo', function (Blueprint $table) {
            $table->dropColumn('address');
        });
    }
}

After run below command


php artisan migrate
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.