迁移表格时,我会看到此错误,
SQLSTATE [42S01]:基本表或视图已存在:1050表“付款”已存在(SQL:创建表
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');
}
}
如果要重新创建表,请php migrate:rollback
首先运行以删除现有表。此命令将down()
在迁移中运行该方法。
然后php migrate
再次运行以创建表。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句