create_auth_tables.php.stub 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use Hyperf\Database\Schema\Schema;
  3. use Hyperf\Database\Schema\Blueprint;
  4. use Hyperf\Database\Migrations\Migration;
  5. class CreateAuthTables extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('auth_rule', function (Blueprint $table) {
  13. $table->increments('id');
  14. $table->unsignedInteger('pid')->default(0)->comment('父级ID');
  15. $table->string('path',100)->default('')->comment('路由地址(前端)');
  16. $table->string('auth',100)->default('')->comment('接口地址(后端)');
  17. $table->string('title',50)->default('')->comment('标题');
  18. $table->string('icon',50)->default('')->comment('图标');
  19. $table->unsignedtinyInteger('ismenu')->default(0)->comment('是否菜单');
  20. $table->integer('weigh')->default(0)->comment('权重');
  21. $table->TinyInteger('status')->default(1)->comment('状态');
  22. $table->string('remark',255)->default('')->comment('注释');
  23. $table->json('remark')->default('')->comment('备注');
  24. });
  25. Schema::create('auth_group',function (Blueprint $table){
  26. $table->increments('id');
  27. $table->unsignedInteger('pid')->default(0)->comment('父级ID');
  28. $table->string('name',50)->default('')->comment('权限组名');
  29. $table->text('rules')->comment('规则ID');
  30. $table->TinyInteger('status')->default(1)->comment('状态');
  31. });
  32. Schema::create('auth_group_access',function (Blueprint $table){
  33. $table->unsignedInteger('uid')->comment('用户ID');
  34. $table->unsignedInteger('group_id')->comment('权限组ID');
  35. });
  36. }
  37. /**
  38. * Reverse the migrations.
  39. */
  40. public function down(): void
  41. {
  42. Schema::dropIfExists('auth_rule');
  43. Schema::dropIfExists('auth_group');
  44. Schema::dropIfExists('auth_group_access');
  45. }
  46. }