1

No matter what command I enter I get the error

"Base table or view not found: 1146 Table 'database.products' doesn't exist

I tried

php artisan migrate:reset
php artisan cache:clear
php artisan optimize
php artisan migrate

and other artisan commands and they all return the above mentioned error. Anyone has idea how to solve this

OunknownO
  • 1,186
  • 3
  • 21
  • 41
  • 1
    give your migration code – Md. Abutaleb Dec 02 '16 at 18:34
  • `grep -R 'database.products' app/*` on your command line will help you find out where it's referenced. – aynber Dec 02 '16 at 18:36
  • i'm using windows – OunknownO Dec 02 '16 at 19:04
  • Oh, sure, make things difficult. Looks like `findstr` should work instead. Try `findstr /S /C:"database.products" app/` ([source](http://stackoverflow.com/questions/698038/windows-recursive-grep-command-line)) – aynber Dec 02 '16 at 19:09
  • @aynber In Laravel `database.products` is unlikely to appear in the code anywhere. Laravel would query that table via something like `Product::all()` or `Product::where()`. – ceejayoz Dec 03 '16 at 00:33

2 Answers2

4

Check your Service Providers (particularly the boot method), make sure none of them are querying models or tables, unless those statements are happening in a closure. This includes any 3rd party providers.

One of the common scenarios is a view()->share(...) that is querying the database.

lagbox
  • 48,571
  • 8
  • 72
  • 83
2

This means you have an error somewhere in your code. You should check all controllers and other classes where you're trying to work with products table. Fix the problem and all artisan commands will work fine.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279