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

eddy1992's avatar

Base table or view not found: 1051 Unknown table after php artisan migrate:refresh

Hi I am facing an issue where I am trying to run php artisan migrate:refresh and every time I run my migration it gives me an error

[Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'mzad-web.adv_filter_categories' (SQL: drop table `adv_filter_categories`)
 [PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'mzad-web.adv_filter_categories'

But when I go and check in the adminer I could see the tables have been dropped. After that If i run php artisan migrate it migrates the tables back again. The only issue is when I try to run php artisan migrate:refresh it gives me this error. Please assist

my migration files I have only two migration files -:

  1. This is the one which is shown in the error.
<?php

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

class CreateAdvFilterCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('adv_filter_categories', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id')->unsigned();
            $table->string('category_name_english');
            $table->string('category_name_arabic');
            $table->boolean('active')->default(1);
            $table->timestamps();
        });
    }

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


Please assist I am stuck with it for such a long time and not able to understand why tis happening.

Thank you

0 likes
7 replies
AddWebContribution's avatar

Rename your current database, create new database with the same name mzad-web and run php artisan migrate command.

Hope this will resolved your issue.

tykus's avatar

It might be that your database is out of sync with your migrations. You can use php artisan migrate:fresh if you are on Laravel 5.5, or pull in the Spatie package if you are on earlier versions. Last option is to manually drop all the tables in your database before running migrations again.

rumm.an's avatar

Just truncate you database and run php artisan migrate. And it should work.

eddy1992's avatar

@tykus Thank you for your response, I am using laravel 5.2 and I tried the option to drop all tables and run migrations again but gave me the same error.

d3xt3r's avatar

Short term solution: use drop if exists ...

tykus's avatar

Are you sure it was the same error? If there were no tables in the database (incl. the migrations table), why would it be trying to drop table adv_filter_categories?

I would be checking the output of the php artisan migrate command to see exactly where the migrations are failing and start working from there - maybe there is an issue with the ordering of migrations - sometimes you might add a foreign key constraint to a table which references one which was not yet created.

jestins's avatar

Follow these steps:

1: truncate migrations table. 2: Drop all the migration tables. 3: run php artisan migrate

Please or to participate in this conversation.