From 02cf6995088df7550591d39333970b0537a44461 Mon Sep 17 00:00:00 2001 From: Seddek Nadhem Date: Fri, 13 Sep 2024 08:18:53 +0300 Subject: [PATCH] Update 2021_11_09_083121_update_users_table.php --- .../task5/2021_11_09_083121_update_users_table.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/database/migrations/task5/2021_11_09_083121_update_users_table.php b/database/migrations/task5/2021_11_09_083121_update_users_table.php index c10976a5..06649e46 100644 --- a/database/migrations/task5/2021_11_09_083121_update_users_table.php +++ b/database/migrations/task5/2021_11_09_083121_update_users_table.php @@ -14,11 +14,14 @@ class UpdateUsersTable extends Migration public function up() { // TASK: add an if-statement in this file to NOT add column if it already exists - Schema::table('users', function (Blueprint $table) { - $table->string('name'); - }); + if (!Schema::hasColumn('users', 'name')) { + Schema::table('users', function (Blueprint $table) { + $table->string('name'); + }); + } + } - + /** * Reverse the migrations. *