No Description

2019_11_13_185313_create_permissions_table.php 908B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreatePermissionsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('permissions', function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->unsignedBigInteger('user_id');
  17. $table->unsignedTinyInteger('level');
  18. $table->unsignedBigInteger('division_id');
  19. $table->unique(['user_id', 'level', 'division_id']);
  20. $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
  21. });
  22. }
  23. /**
  24. * Reverse the migrations.
  25. *
  26. * @return void
  27. */
  28. public function down()
  29. {
  30. Schema::dropIfExists('permissions');
  31. }
  32. }