简体   繁体   中英

laravel migration:rollback gives error

I have 2 migration tables and I migrated them succesfully. However I forgot to add something so I tried to rollback

  php artisan migrate:rollback

After this command I received these errors .

[Illuminate\\Database\\QueryException] SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'table name' (SQL: drop table table name )

[PDOException] SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'table name'

Migrations were successfull. However when I rolled back it could not found the table that I just migrated.

   <?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');
}

}

and this is my seconda table

<?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');

}

}

In your second migration, inside the down method, you're droping the table online_diyet previously droping in your first migration.

it should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM