Here, i have come with another small piece of code which you can use in updating your laravel existing migrations.
Run this command to create migration
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 this command
run the command php artisan migrate
Please like share and give positive feedback to motivate me to write more.
For more tutorials visit my website.
Thanks:)
Happy Coding:)
Top comments (0)