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
@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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community