Silvanite / novatoolpermissions

Laravel Nova Permissions Tool (User, Roles and Permissions / Access Control (ACL))
MIT License
101 stars 33 forks source link

migration failed #42

Closed perlbrain closed 5 years ago

perlbrain commented 5 years ago

hi,

I have installed nova and the table users included ofcourse. Then tried to install novatoolpermissions. First step not a problem composer require silvanite/novatoolpermissions Second step php artisan migrate, is a problem. The users table already exists. Then I renamed the current users table and tried again php artisan migrate. Excess violantion: 1071 specified Key too long.

How to resolve this.

regards,

Bryan

perlbrain commented 5 years ago

Just found this solution:

https://laravel-news.com/laravel-5-4-key-too-long-error

patricktsg commented 5 years ago

If your using laravel 5.8 the increments has changed to bigIncrements on ID columns, change it to increments and it will work.

m2de commented 5 years ago

Yeah, I'm still trying to decide how to deal with this annoying change in 5.8. More of a Brandenburg issue though.

nemrutco commented 5 years ago

any update on this issue? or any temp solution? even i try to change id on roles table to bigIncrements, still having some issues with role_permission` (errno: 150 "Foreign key constraint is incorrectly formed"

nemrutco commented 5 years ago

temp solution :

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGatesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 'admin', 'editor'
        Schema::create('roles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('slug');
            $table->string('name')->nullable();
            $table->timestamps();
        });

        Schema::create('role_permission', function (Blueprint $table) {
            $table->bigInteger('role_id')->unsigned();
            $table->string('permission_slug');
            $table->timestamps();

            $table->foreign('role_id')
                ->references('id')
                ->on('roles')
                ->onDelete('cascade');

            $table->primary(['role_id', 'permission_slug']);
        });

        Schema::create('role_user', function (Blueprint $table) {
            $table->bigInteger('role_id')->unsigned();
            $table->bigInteger('user_id')->unsigned();
            $table->timestamps();

            $table->foreign('role_id')
                ->references('id')
                ->on('roles')
                ->onDelete('cascade');

            $table->foreign('user_id')
                ->references('id')
                ->on('users')
                ->onDelete('cascade');

            $table->primary(['role_id', 'user_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('role_permission');
        Schema::dropIfExists('role_user');
        Schema::dropIfExists('roles');
    }
}

change integer to bigInteger and increments to bigIncrements at brandenburg/src/Database/Migrations/2017_05_28_115649_create_gates_table.php

m2de commented 5 years ago

Brandenburg has been updated to use the big int for Laravel 5.8, so this should now be resolved. Please re-open if you still experience an issue. Cheers.