Laravel migration update table
php artisan make:migration update_users_table
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('name', 255)->nullable(true)->change();
$table->renameColumn('first_name', 'full_name');
$table->dropColumn('age');
$table->string('email')->unique()->change();
$table->integer('gender');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->string('name', 255)->nullable(false)->change();
$table->renameColumn('full_name', 'first_name');
$table->integer('age');
$table->dropUnique('email');
$table->dropColumn('gender');
});
}
};
Now, run the command php artisan migrate