当我将表迁移到 db 时,出现此错误SQLSTATE[42S01]: 基表或视图已经存在:1050 表 'users' 已经存在(SQL:创建表users(idint unsigned not null auto_increment 主键,bodylongtext not null,url varchar(255) null,user_id int unsigned not null,commentable_id int unsigned not null, commentable_typevarchar(191) not null, created_a ttimestamp null, updated_attimestamp null) 默认字符集 utf8mb4 collate utf8mb4_unicode_ci) 在 Connection.php 第 449 行:SQLSTATE[42S01]:基表或视图已经存在:1050 表 'users' 已经存在<?phpuse Illuminate\Support\Facades\Schema;use Illuminate\Database\Schema\Blueprint;use Illuminate\Database\Migrations\Migration;class CreateUsersTable extends Migration{ /** * Run the migrations. * * @return void */ public function up() { if(!Schema::hasTable('users')){ Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table-> string('name'); $table-> string('email')->unique(); $table-> string('password'); $table->rememberToken(); $table->timestamps(); }); } Schema::table('users', function(Blueprint $table){ $table -> string('first_name') -> nullabel(); $table -> string('middle_name') -> nullabel(); $table -> string('last_name') -> nullabel(); $table -> string('city') -> nullabel(); $table -> integer('role') -> unsigned(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); }我从数据库中删除了所有表然后我尝试但给出了同样的错误
2 回答
- 2 回答
- 0 关注
- 194 浏览
添加回答
举报
0/150
提交
取消