0

When I run php artisan migrate i get error B

Base table or view already exists: 1050 Table 'categories' already exists'

What is it? Why? How to find error? My categories migrations file:

<?php

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

class CategoriesTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {

            $table->increments('id');

            $table->string('title')->index();
            $table->text('description');

            $table->integer('attachment_id')->unsigned()->index();
            $table->foreign('attachment_id')->references('id')->on('attachment')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }

}
engilexial
  • 153
  • 1
  • 3
  • 14

2 Answers2

0

In that migration file, the function drop() should be

public function down()
{
    Schema::drop('categories');
}
0

It seems that you try to create existing table..

so i think you are editing the migration file that you already installed

you can drop your database and re-migrate it

php artisan migrate:reset

then

php artisan migrate