gpt4 book ai didi

php - SQLSTATE[42S01] : Base table or view already exists: 1050 Table 'payments' already exists (SQL: create table `payments`

转载 作者:行者123 更新时间:2023-11-29 02:12:36 24 4
gpt4 key购买 nike

当我迁移一个表时,我看到了这个错误,

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'payments' already exists (SQL: create table payments

<?php

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

class CreatePaymentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payments', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('resnumber');
$table->string('course_id')->default('vip');
$table->string('price');
$table->boolean('payment')->default(false);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('payments');
}
}

Error

最佳答案

如果您使用的是 Laravel 5.5,则可以执行 php artisan migrate:fresh。此命令将删除所有表,然后重新创建它们。希望对您有所帮助。

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

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