framework: #php artisan >>> Base table or view not found: ...
Tonight after rolling back all my migrations, I did a php artisan migrate
and got:
{"error":{"type":"Illuminate\\Database\\QueryException","message":"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my_database.my_table' doesn't exist (SQL: select * from `my_table` where `enabled` = yes order by `name` asc)","file":"\/vhosts\/mysite.local\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Connection.php","line":555}}
root@server:/vhosts/mysite.local
The funny thing is, I’ve been doing php artisan migrate:refresh
for days with this setup without issue.
At first I thought it was some class file was calling my table and I needed to refresh the composer autoload:
# php artisan dump-autoload
SAME ERROR. Then I just tried # php artisan
. SAME ERROR.
What is going on? I can’t even dump my autoload or run ANY artisan commands. What would be automatically running that is calling my database tables while running the default artisan
command?
routes.php
only points to controller methods, no SQL in that file.
I removed my view composers as well just incase they were running for some weird reason.
bootstrap/start.php
contains no DB queries.
global.php
contains no DB queries.
Can’t figure this out. And I can’t get a more -verbose
error to show up.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 1
- Comments: 17 (4 by maintainers)
for me , its was in the boot method of the app service provider as i set up a view::share() and i have already changed the database.
Correction on this for anyone interested. It was the constructor of the command that runs every time and thats where my query was. So that is good to know.
I woke up this morning and realized where this was coming from.
For anyone interested, in one of my custom artisan commands, I set my options and arguments for the command based off the contents of a DB table with a query. Since the table didn’t exist, it bombed out for ALL artisan commands, not just my custom one. So that is interesting that artisan fetches the options and arguments for each valid artisan command even if you are just running
# php artisan
.Also, like I said, I’ve been doing
# php artisan migrate:refresh
a lot without this issue and it makes sense now, because when I ran the command, the tables were all rollback and then recreated every time. It was only this time when I did amigrate:rollback
, destroying my table, and now I couldn’tmigrate
forward since the table didn’t exist anymore.Yeah sorry realized I should have gone to the forums with this too.
@z-Shahsavan This is likely not related to the change you made to the migration but more that you’re using your permissions table somewhere too early in Laravel’s cycle where it crashes because it’s missing before it even gets to creating it. Somewhere in a routes file or something. Check my way earlier message.
@devqx thx!
Thanks for the comment @devqx , I had the same issue and You saved me a lot of time.