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. *