Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrisgrim's avatar

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

I have rolled back all my migrations so there is nothing in my table. When I try to do anything with php artisan (even just php artisan tinker) I am getting the error

In Connection.php line 664:

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


In Connection.php line 326:

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

I tried connecting to a new database but still getting the error. I do have the migration file for category

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('slug');
            $table->string('name');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('categories');
    }
}

I have even tried to do adjust the categories.php model to name the table

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
  public $table = "categories";
  protected $guarded = [];
  protected $with = ['roundups'];
    public function getRouteKeyName()
    {
        return 'slug';
    }
    public function roundups()
    {
        return $this->hasMany(Roundup::class);
    }
}

I am stuck and don't know how to move forward. I tried deleting all my routes and I am still getting the error. Thanks so much for any help!

0 likes
8 replies
Ty's avatar

Did you also make sure the migration table was empty as well? I have ran into this issue before where if the migrations table still had data I had this error.

munazzil's avatar

Have you check in your seeder there is having any database migration table that wants to remove?.

chrisgrim's avatar
chrisgrim
OP
Best Answer
Level 10

Oh man I finally figured it out. I had added code to my AppServiceProvider public boot function that was calling on that table to show in each view!

3 likes
onesignco's avatar

@chrisgrim hi ,I've been facing this issue, please what line of code did you to AppServiceProvider public root function that solve the problem? i will be glad if you can help out. thank you

1 like
chrisgrim's avatar

@onesignco I am so sorry but I tried to go back and see what my issue was but I wasn't able to find it. I believe it was something to do with loading a model for each page.

1 like
Bazoooka's avatar

@chrisgrim Man after 3 days I saw your comment and it was the best Hint in the internet to get ride of the issue ! Thanks dude

Please or to participate in this conversation.