Base table or view not found: 1146 Table 'db.ken_permissions' doesn't exist

- 1 answer

Ad

Sometimes, when I type :

php artisan 
php artisan migrate
etc

I get the message:

  [Illuminate\Database\QueryException]                                         
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.ken_permissions' doesn't exist (SQL: select * from `ken_permissions`)

Debugging, I can tell my problem happens in the artisan file in:

$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

I had already check this answer, and didn't work:

bootstrap/app.php is clean,

I don't have app/start folder ( L5.1),

routes.php is clean

php artisan -v or php artisan --pretend doesn't work, because artisan fails before running it seems.

The only thing I have is in app/Providers

    public function boot(GateContract $gate)
{
    parent::registerPolicies($gate);
    // Dynamically register permissions with Laravel's Gate.
    foreach ($this->getPermissions() as $permission) {
        $gate->define($permission->name, function ($user) use ($permission) {
            return $user->hasPermission($permission);
        });
    }
}

One solution is to delete all my tables, then composer dump-autoload, and then it work again, but it constantly comes back.

Is it a way to trace what migration is failing? Any idea why is it happening?

Tx!

Ad

Answer

Ad

Go to the App\Provider\AuthServiceProvider if you use on boot method GateContract ($this->getPermission() etc), remove or add to comment all after parent::registerPolicies($gate); and done run php artisan migrate

Ad
source: stackoverflow.com
Ad