Can't start Laravel, I get “Base table or view not found” error

后端 未结 5 1354
无人共我
无人共我 2021-02-20 16:52

First I rolled back 2 migrations by mistake, then I ran php artisan migrate command and I got the following error:

[Illuminate\\Database\\QueryExcepti

5条回答
  •  自闭症患者
    2021-02-20 17:12

    If you encounter with this problem and if it's not caused by migration files then most probably it happens because of 2 possible reasons.

    1. Check ServiceProviders' boot function if it contains queries that are querying tables that don't exist.
    2. Check if you've created custom helper function and autoloaded that helper function in composer.json file. If custom helper function contains queries that are querying tables that don't exist it will cause this error.

    Since ServiceProviders' boot functions and autoloaded custom helper functions are loaded first when laravel is started all the php artisan commands will generate "Base table or view not found" error.

    At this point what you should do is comment out those queries that are querying nonexistent tables and run php artisan serve then run php artisan migrate. Then uncomment those lines, save it and everything should work fine.

    As @devk suggested it's better to check laravel log files which points exactly to where the problem happens. It led me to find a solution. For this don't forget to Turn on debug mode.

提交回复
热议问题