Make Migration - php artisan make:migration new_column_name --table=existing_table_name
Do Change Migration File like following :
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->after('password', function (Blueprint $table) {
$table->integer('created_id')->nullable();
});
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('created_id');
});
}
};
After That Migrate Specific Migration File
php artisan migrate:refresh --path=database/migrations/2023_10_12_160607_created_id.php


No comments:
Post a Comment