SQLSTATE [42S01]:基本表或视图已存在:1050表“付款"已存在(SQL:创建表“付款" [英] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'payments' already exists (SQL: create table `payments`

查看:228
本文介绍了SQLSTATE [42S01]:基本表或视图已存在:1050表“付款"已存在(SQL:创建表“付款"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我迁移表时,我看到此错误,

When I migrate a table I see this error,

SQLSTATE [42S01]:基表或视图已存在:1050表 付款"已经存在(SQL:创建表payments

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

错误

推荐答案

如果要重新创建表,请运行

If you want to recreate the table, run php migrate:rollback first to delete the existing one. This command will run the down() method in the migration.

然后运行php migrate再次创建表.

这篇关于SQLSTATE [42S01]:基本表或视图已存在:1050表“付款"已存在(SQL:创建表“付款"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆