Back

SQLSTATE[42S02]: Base table or view not found: 1146 Table


Tofayal posted 7 months ago

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cruds.users' doesn't exist (SQL: select * from users)

this error how to solve it.

Luis Terrero replied 7 months ago

Can you explain better? Where and how exactly are you getting this?

minikN replied 7 months ago

I'm getting the same error. I updated the framework today from 5.5.20 to 5.5.22 using composer update.

A couple of hours later I wanted to rollback my migrations and did

php artisan migrate:rollback

which worked. However after that the framework completely broke. Now I'm getting the following:

In Connection.php line 664:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.pages'
   doesn't exist (SQL: select * from `pages`)


In Connection.php line 326:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.pages'
   doesn't exist

...no matter what I do, I get it if I run

php artisan
composer update
composer dump-autoload
Yorick van Klinken replied 6 months ago

I made a account just to say I've had the same problem and I found what went wrong:

I added an ACL/permission/role system of my own creation and put code for it in AuthServiceProvider. There the code would take all permissions from the db and load them as a Gate. The problem was that this code is run every time you do something laravel related, so even console when you didn't have the migrations yet.

My fix:

if (App::runningInConsole() && !App::environment('testing')) {
     return;
}

I hope this is still of some use for someone


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us