Laravel - 表在运行迁移时已存在

时间:2018-06-06 15:14:08

标签: php laravel-5 eloquent

首先,请原谅我的英语,这不是我原生的语言,需要更多练习

在我的项目中,我正在使用laravel 5.5,并且我在项目中使用的每个数据库都有2个不同的模式。现在,当我运行迁移时,这工作完美,创建所有表,索引,外键和我需要的所有内容,但是,当我需要撤消迁移时,我收到错误,因为表已经存在

public function up()
    {
        Schema::connection('empresa')->create('almacenes', function (Blueprint $table) {
            $table->tinyIncrements('id');
            $table->string('name',30)->index();
            $table->string('address',120)->nullable();
            $table->tinyInteger('orden')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('empresa')->dropIfExists('almacenes');
    }

这是我的迁移文件的代码,我尝试了针对down函数的不同代码而没有。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您需要回滚之前的迁移或将迁移文件重命名为更新的日期,以便再次加载,更多信息:https://laravel.com/docs/5.6/migrations#rolling-back-migrations