1

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!

Juliatzin
  • 18,455
  • 40
  • 166
  • 325

2 Answers2

4

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

Orange_shadow
  • 199
  • 2
  • 9
0

Adding to watcher's answer here

Remove any lines requesting data from your model from these files to be sure artisan is not trying to load data from your non-existent table:

bootstrap/start.php
app/start/global.php
app/start/local.php
app/routes.php
Also be sure to un-register any service providers that utilize data from that table in their register or boot methods inside of app/config/app.php.

You can move your migrations to a database/temp folder and run your migrations one by one php artisan migrate --path=database/temp you will know which migration is causing problem.
NOTE
Also you can use php artisan migrate --pretend to get the query you are trying to do.

Community
  • 1
  • 1
StealthTrails
  • 2,281
  • 8
  • 43
  • 67