Skip to content

Commit

Permalink
Updated Users table with role_id and status_id as FK
Browse files Browse the repository at this point in the history
  • Loading branch information
meowfu0 committed Oct 6, 2024
1 parent 00b218a commit 335ceb4
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddRoleAndStatusToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->unsignedBigInteger('role_id')->nullable();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('set null');

$table->unsignedBigInteger('status_id')->nullable();
$table->foreign('status_id')->references('id')->on('statuses')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['role_id']);
$table->dropForeign(['status_id']);
$table->dropColumn(['role_id', 'status_id']);
});
}
}

0 comments on commit 335ceb4

Please sign in to comment.