Skip to content

Commit

Permalink
Modify UpdateUsersTable.php
Browse files Browse the repository at this point in the history
  • Loading branch information
amosfolz committed Jun 19, 2019
1 parent abe23cc commit c731414
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* See https://laravel.com/docs/5.4/migrations#tables
*
* @author Alex Weissman (https://alexanderweissman.com)
* @author Amos Folz
*/
class UpdateUsersTable extends Migration
{
Expand All @@ -40,11 +40,7 @@ public function up()
{
if ($this->schema->hasTable('users')) {
$this->schema->table('users', function (Blueprint $table) {
$table->dropForeign(['group_id']);
$table->unsignedInteger('group_id')->default(null)->comment('The id of the user group.')->nullable()->change();
});
$this->schema->table('users', function (Blueprint $table) {
$table->foreign('group_id')->references('id')->on('groups');
$table->unsignedInteger('group_id')->comment('The id of the user group.')->nullable()->change();
});
}
}
Expand All @@ -55,11 +51,7 @@ public function up()
public function down()
{
$this->schema->table('users', function (Blueprint $table) {
$table->dropForeign(['group_id']);
$table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->nullable(false)->change();
});
$this->schema->table('users', function (Blueprint $table) {
$table->foreign('group_id')->references('id')->on('groups');
});
}
}

0 comments on commit c731414

Please sign in to comment.