Skip to content

Commit

Permalink
T5 2021_11_09_083121_update_users_table.php
Browse files Browse the repository at this point in the history
  • Loading branch information
imtyaz-17 authored Jul 3, 2024
1 parent 1dab0d4 commit 0b0b494
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ 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')){
$table->string('name');
}
});
}

Expand All @@ -27,5 +29,10 @@ public function up()
public function down()
{
//
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'name')) {
$table->dropColumn('name');
}
});
}
}

0 comments on commit 0b0b494

Please sign in to comment.