Noob Coder
Noob Coder

Reputation: 2896

Laravel 5.2 base table or view not found error

i have just started working with laravel 5.2.. this is a simple migration file but when i run the php artisan migrate command i get the error shown on the screenshot. what should i do now?

migration file

<?php

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

class CreateProductCategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('product_category', function (Blueprint $table) {
            $table->increments('id');
            $table->string('product_category_name');
            $table->timestamps();
        });
    }

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

enter image description here

Upvotes: 1

Views: 345

Answers (2)

armyofda12mnkeys
armyofda12mnkeys

Reputation: 3442

For me, it was because i was dynamically registering Scheduled Tasks in Kernel.php via my own custom Task object by loop over Task::all(). But my 'task' db table wasn't created yet causing the error. so I commented out the Kernel.php code, ran the php artisan migrate command then uncommented my Kernel.php code. Not sure, but may be best to just do a try{ dbCode; } catch{doNothing;} in the Kernel.php code.

Upvotes: 0

Ben Harold
Ben Harold

Reputation: 6432

You need to change Schema::table to Schema::create.

Upvotes: 3

Related Questions