-
php artisan make:migration add_colName_to_tableName --table=tableName
This will create migration file under the database/migration directory
- Update in the generated file the columns you want to add in the up function. Also add instruction to delete the columns in the down function.
public function up() { Schema::table('tableName', function (Blueprint $table) { $table->string('addCol1')->nullable(); $table->string('addCol2')->nullable(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('tableName', function (Blueprint $table) { $table->dropColumn(['addCol1', 'addCol2']); }); }
- Now run
php artisan migrate
You should see the new columns created