当我运行php artisan migrate
时,我收到错误B
基本表或视图已存在:1050表'类别'已经 存在'
这是什么?为什么?如何找到错误? 我的类别迁移文件:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('title')->index();
$table->text('description');
$table->integer('attachment_id')->unsigned()->index();
$table->foreign('attachment_id')->references('id')->on('attachment')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
答案 0 :(得分:0)
在该迁移文件中,函数drop()应为
public function down()
{
Schema::drop('categories');
}
答案 1 :(得分:0)
您似乎尝试创建现有表..
所以我认为您正在编辑已安装的迁移文件
您可以删除数据库并重新迁移
php artisan migrate:reset
然后
php artisan migrate