-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Users table with role_id and status_id as FK
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
database/migrations/2024_10_06_105914_add_role_and_status_to_users_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | ||
}); | ||
} | ||
} | ||
|