laravel 外键schema RBAC

时间:2022-08-24 20:32:20

$table->bigIncrements('id')  ;   Incrementing ID (primary key) using a " UNSIGNED BIG INTEGER" equivalent.

$table->increments('id')

$table->smallIncrements('id')

        Schema::create('roles', function (Blueprint $table) {
$table->tinyInteger('id')->unsigned()->autoIncrement();
$table->string('name');
$table->string('display_name');
}); Schema::create('permissions', function (Blueprint $table) {
$table->smallIncrements('id');
$table->string('name');
$table->string('display_name');
}); Schema::create('permission_role', function (Blueprint $table) {
$table->smallInteger('permission_id')->unsigned();
$table->tinyInteger('role_id')->unsigned();
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
});

smallint  65535
tinyint   255