laravel migration:rollback给出错误

时间:2016-07-06 14:51:09

标签: php laravel migration

我有2个迁移表,我成功迁移了它们。但是我忘了添加一些东西,所以我试图回滚

  php artisan migrate:rollback

在此命令之后,我收到了这些错误。

  

[照亮\数据库\ QueryException]         SQLSTATE [42S02]:找不到基表或视图:1051未知表'表名' (SQL:drop table table name

     

[PDOException]       SQLSTATE [42S02]:找不到基表或视图:1051未知表'表名'

迁移是成功的。但是,当我回滚时,它找不到我刚刚迁移的表。

   <?php

 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;

class OnlineDiyet extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('online_diyet',function (Blueprint $table){
        $table->increments('id');


        $table->string('bilgi');
        $table->rememberToken();
        $table->timestamps();

    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('online_diyet');
}

}

这是我的第二张表

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

  class Doctors extends Migration
  {
/**
 * Run the migrations.
 *
 * @return void
 */
   public function up()
   {
    Schema::create('doctors',function (Blueprint $table) {

        $table->increments('id');
        $table->string('email');
        $table->boolean('mailat',1);
        $table->rememberToken();
        $table->timestamps();


    });        
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('online_diyet');

}

}

1 个答案:

答案 0 :(得分:0)

在第二次迁移中,在down方法中,您放弃了先前迁移中丢失的表online_diyet

它应该是:

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