Add new column in existing table

  • Firstly create a new migration say “php artisan make:migration update_products”
  • Then add table in place of create in the following migration code:
Schema::table('products', function (Blueprint $table) {
   $table->string('name');
   $table->smallInteger('publication_status')->nullable()->change() ;
});

Note: Make sure to add doctrine/dbal package which is required whenever you make any changes in the existing table through migration.

Command: composer require doctrine/dbal

Leave a Reply

Your email address will not be published. Required fields are marked *