SQLSTATE [42S01]:基本表或视图已存在或基本表或视图已存在:1050表

pra*_*rel 2 php laravel-5.4

这是我的迁移表

    <?php

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

class CreateUserTable extends Migration
{

    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('role_id')->unsigned();
            $table->string('name');
            $table->string('email',50)->unique();
            $table->string('username');
            $table->string('password');
            $table->boolean('active');
            $table->rememberToken();
            $table->timestamps();

        });
    }

    public function down()
    {
        Schema::dropIfExists('users');
    }
}
Run Code Online (Sandbox Code Playgroud)

每当我尝试迁移时,都会发生以下错误

* [Illuminate \ Database \ QueryException] SQLSTATE [42S01]:基本表或视图已经存在:1050表'user'确实存在(SQL:创建表usersidint unsigned not null auto_increment主键,role_idint unsigned not null,namevarchar( 191)不为空,emailvarchar(50)不为空,usernamevarchar(191)不为空,pas swordvarchar(191)不为空,activetinyint(1)不为空,remember_token varchar(100)为空,created_at时间戳为null,updated_at时间戳为nu ll)默认字符集utf8mb4整理utf8mb4_unicode_ci)

[PDOException] SQLSTATE [42S01]:基本表或视图已存在:1050表'用户'确实存在*

请告诉我该怎么办?我已经使用过migration:reset或dumpautoload或rollback没有任何反应。很多时间,我编辑或删除了这个usersfile并重新创建了它。

小智 5

这样尝试

   <?php

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

class CreateUserTable extends Migration
{

    public function up()
    {
        Schema::dropIfExists('users');
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('role_id')->unsigned();
            $table->string('name');
            $table->string('email',50)->unique();
            $table->string('username');
            $table->string('password');
            $table->boolean('active');
            $table->rememberToken();
            $table->timestamps();

        });
    }

    public function down()
    {
        Schema::dropIfExists('users');
    }
}
Run Code Online (Sandbox Code Playgroud)