gpt4 book ai didi

php - SQLSTATE[42S01] : Base table or view already exists or Base table or view already exists: 1050 Table

转载 作者:行者123 更新时间:2023-12-03 01:20:21 24 4
gpt4 key购买 nike

这是我的迁移表

    <?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');
}
}

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

*[照亮\数据库\QueryException]SQLSTATE[42S01]:基表或 View 已存在:1050 表“用户”已存在ady 存在(SQL:创建表 users ( id int unsigned not null auto_increment 主键,role_id int 无符号非空,name varchar(191) 不 空,email varchar(50) 不为空,username varchar(191) 不为空,pas
sword
varchar(191) 不为空,active tinyint(1) 不为空,remember_token
varchar(100) 空, created_at时间戳为空,updated_at时间戳 null) 默认字符集utf8mb4 collat​​e utf8mb4_unicode_ci)

[PDO异常]SQLSTATE[42S01]:基表或 View 已存在:1050 表“用户”已存在ady 存在*

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

最佳答案

尝试这样

   <?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');
}
}

关于php - SQLSTATE[42S01] : Base table or view already exists or Base table or view already exists: 1050 Table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44141475/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com