dimanche 28 juillet 2019

How to fix 'SQLSTATE[42S01]:base table or view already exists' error in laravel

When I migrate the file then it shows me a this error (image link given).I've tried migrate:rollback ,migrate:refresh but it didn't work.

https://i.imgur.com/oFjcadB.png

<?php

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

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->unsigned();
            $table->integer('category_id')->unsigned();
            $table->string('title', 128);
            $table->longText('content');
            $table->string('thumbnail_path', 128);
            $table->string('status', 32)->default('draft');
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
        });
    }

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire