【问题标题】:laravel migration:rollback gives errorlaravel 迁移:回滚给出错误
【发布时间】:2023-04-06 05:54:01
【问题描述】:

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

  php artisan migrate:rollback

执行此命令后,我收到了这些错误。

[照亮\数据库\查询异常] SQLSTATE[42S02]:未找到基表或视图:1051 未知表“表名”(SQL:删除表table name

[PDO异常] 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');

}

}

【问题讨论】:

  • 您能向我们展示您的迁移文件吗?
  • @AliYiğit 包括向上和向下的整个迁移文件
  • 我在问题上编辑了它

标签: php laravel migration


【解决方案1】:

在您的第二次迁移中,在 down 方法中,您将删除表 online_diyet,该表之前在您的第一次迁移中删除。

应该是:

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

【讨论】:

    猜你喜欢
    • 2017-03-08
    • 2016-10-18
    • 2021-07-01
    • 2017-04-18
    • 2014-12-06
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 2017-07-31
    相关资源
    最近更新 更多