Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel迁移错误_Php_Laravel_Laravel 5 - Fatal编程技术网

Php Laravel迁移错误

Php Laravel迁移错误,php,laravel,laravel-5,Php,Laravel,Laravel 5,当我运行php artisan migrate时,我得到错误B 基本表或视图已存在:1050表“类别”已存在 存在' 这是什么?为什么?如何发现错误? 我的类别迁移文件: <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; class CategoriesTable extends Migration { /** * Run the

当我运行
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()
    {
        //
    }

}

在该迁移文件中,函数drop()应该是

public function down()
{
    Schema::drop('categories');
}

您似乎试图创建现有表

因此,我认为您正在编辑已安装的迁移文件

您可以删除数据库并重新迁移它

php artisan migrate:reset
然后


听起来您的数据库中已经存在该表。。你检查过没有吗?即使我删除了表,错误仍然存在。不是这样吗?你是怎么删除表格的?似乎您尚未在迁移文件中定义
down()
方法,因此artisan不会删除该表。请检查您的数据库配置文件以及使用的数据库。已触发一些迁移并创建了一些表。但并非全部
php artisan migrate