當(dāng)我將表遷移到 db 時,出現(xiàn)此錯誤SQLSTATE[42S01]: 基表或視圖已經(jīng)存在:1050 表 'users' 已經(jīng)存在(SQL:創(chuàng)建表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]:基表或視圖已經(jīng)存在:1050 表 'users' 已經(jīng)存在<?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'); }我從數(shù)據(jù)庫中刪除了所有表然后我嘗試但給出了同樣的錯誤
- 2 回答
- 0 關(guān)注
- 220 瀏覽
添加回答
舉報
0/150
提交
取消