Я просто не понимаю, как происходит эта ошибка при запуске php artisan migrate
после создания новой таблицы.
Я искал в Интернете и SO и пробовал каждое отдельное предложение (например, php artisan migrate:fresh
), но, похоже, ничего не работает.
Что я могу сделать, чтобы исправить эту проблему, поскольку это задерживает меня?
SQLSTATE[42S01]: Base table or view already exists: 1050 Table
'posts' already exists (SQL: create table `posts` (`id` bigint
unsigned not null auto_increment primary key, `user_id` int
unsigned not null, `body` varchar(140) not null, `created_at`
timestamp null, `updated_at` timestamp null) default character set
utf8mb4 collate 'utf8mb4_unicode_ci')
Миграция:
<?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->string('body', 140);
$table->timestamps();
$table->foreign('user_id')->references('id')->on('user')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
}


