運行 php artisan migrate 時出現以下錯誤
我的終端:
INFO 正在運行遷移。
2014_10_12_000000_create_users_table .................................................. ..................................................... . 3ms 失敗
照亮\資料庫\查詢例外
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table `users` (`id` bigint unsigned not null auto_increment primary key, `name` var
char(191) not null, `email` varchar(191) not null, `email_verified_at` timestamp null, `password` varchar(191) not null, `utype` varchar(191) not null default 'USR' comment 'ADM - Admi
n ucun, USR - normal isdifadeci user ucun', `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
at C:\wamp64\www\laravel9ecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:759
755▕ // If an exception occurs when attempting to run a query, we'll format the error
756▕ // message to include the bindings with SQL, which will make this exception a
757▕ // lot more helpful to the developer instead of just the database's errors.
758▕ catch (Exception $e) {
? 759▕ throw new QueryException(
760▕ $query, $this->prepareBindings($bindings), $e
761▕ );
762▕ }
763▕ }
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('utype')->default('USR')->comment('ADM - for admin, USR - for normal user');
$table->rememberToken();
$table->timestamps();
});
}
uj5u.com熱心網友回復:
正如所提到的錯誤,看起來該users表已經創建。你可以運行:
php artisan migrate:fresh --seed
但是,請注意,這將洗掉所有表并再次運行遷移。如果migrate:fresh不是您的選擇,您可以手動在遷移表中插入一行,并使用該用戶表的檔案名。示例INSERT INTO遷移 (id, 遷移, 批處理) VALUES (NULL, '2014_10_12_000000_create_users_table', '1');
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/514629.html
標籤:php拉拉维尔
