singleloginsystem/database/migrations/2026_05_18_113635_app_roles.php
= 495c0ea2d8 Feat: add app roles management and relationships
- Added `app_roles` migration to manage role assignments for connected apps, supporting role duration and indexing.
- Introduced `AppRole` pivot model for managing `ConnectedApp` and `Role` relationships.
- Updated `ConnectedApp` and `Role` models with `BelongsToMany` relationships for role associations.
- Adjusted `permission` config to use custom `Role` model.
2026-05-19 07:16:17 +00:00

34 lines
826 B
PHP

<?php
declare(strict_types=1);
use App\Models\ConnectedApp;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('app_roles', function (Blueprint $table): void {
$table->id();
$table->foreignIdFor(ConnectedApp::class, 'app_id');
$table->foreignId('role_id')->comment('role_id from spatie roles table');
$table->integer('duration')->comment('in days');
$table->index(['app_id', 'role_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('app_roles');
}
};