add role route override and user data scope

This commit is contained in:
2026-03-09 14:14:21 +08:00
parent ac640cc813
commit 679463d2c1
4 changed files with 161 additions and 0 deletions
@@ -0,0 +1,32 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('role_route_overrides', function (Blueprint $table) {
$table->unsignedBigInteger('role_id')->comment('角色 ID');
$table->unsignedBigInteger('route_id')->comment('路由 ID');
$table->boolean('allowed')->comment('true=强制允许, false=强制拒绝');
$table->primary(['role_id', 'route_id']);
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->foreign('route_id')->references('id')->on('routes')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('role_route_overrides');
}
};
@@ -0,0 +1,34 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_data_scopes', function (Blueprint $table) {
$table->id()->comment('主键');
$table->unsignedBigInteger('user_id')->comment('用户 ID');
$table->string('scope_type', 20)->comment('范围类型: company/platform/store');
$table->unsignedBigInteger('scope_id')->comment('范围目标 ID');
$table->timestampTz('created_at')->useCurrent()->comment('创建时间');
$table->unique(['user_id', 'scope_type', 'scope_id']);
$table->index('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_data_scopes');
}
};