0

I made a Laravel project with Jetstream and uploaded it to Github. After my colleague and I tried to execute composer install, we received the following error:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Illuminate\Database\QueryException 

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

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:742
    738▕         // If an exception occurs when attempting to run a query, we'll format the error
    739▕         // message to include the bindings with SQL, which will make this exception a
    740▕         // lot more helpful to the developer instead of just the database's errors.
    741▕         catch (Exception $e) {
  ➜ 742▕             throw new QueryException(
    743▕                 $query, $this->prepareBindings($bindings), $e
    744▕             );
    745▕         }
    746▕     }

  1   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\RouteServiceProvider))

      +15 vendor frames 
  17  routes/web.php:20
      Illuminate\Database\Eloquent\Model::__callStatic("first", [])
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

We tried again without the scripts in composer.json, went well, but after each and every artisan-command we try, we get the following exception:


In Connection.php line 742:
                                                                               
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.users' doesn't exist (SQL: select * from `users` limit 1)                  
                                                                               

In Connection.php line 396:
                                                                               
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.users' doesn't exist                                                       

This also happens when we try to execute php artisan migrate, the command which should solve this error.

So, what can we try now?

  • Did you change the name of the users table (like you named it user instead)? You should have a model named User and the table should be called users. Your migration should reflect that. If you add the migration to your question it would help. – Paulo Hgo May 24 '22 at 19:44

1 Answers1

0

If you're getting this error by running every "php artisan" command, then you might query database during the bootstrapping process and because of the empty database, this error keeps throwing. you might need to check all places you have queried the database for users (maybe in providers)

Sahand Moghadam
  • 447
  • 4
  • 9