【问题标题】:Laravel 5.2 base table or view not found errorLaravel 5.2 未找到基表或视图错误
【发布时间】:2016-04-16 13:28:31
【问题描述】:

我刚刚开始使用 laravel 5.2.. 这是一个简单的迁移文件,但是当我运行 php artisan migrate 命令时,我得到了屏幕截图中显示的错误。我现在该怎么办?

迁移文件

<?php

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

class CreateProductCategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('product_category', function (Blueprint $table) {
            $table->increments('id');
            $table->string('product_category_name');
            $table->timestamps();
        });
    }

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

【问题讨论】:

    标签: php laravel database-migration laravel-artisan laravel-5.2


    【解决方案1】:

    您需要将Schema::table 更改为Schema::create。

    【讨论】:

      【解决方案2】:

      对我来说,这是因为我通过循环在 Task::all() 上通过我自己的自定义任务对象在 Kernel.php 中动态注册计划任务。但我的“任务”数据库表尚未创建导致错误。所以我注释掉了 Kernel.php 代码,运行 php artisan migrate 命令然后取消注释我的 Kernel.php 代码。 不确定,但最好只是尝试一下{ dbCode; } catch{doNothing;} 在 Kernel.php 代码中。

      【讨论】:

        猜你喜欢
        • 2016-09-23
        • 2019-06-09
        • 2016-07-15
        • 2020-03-13
        • 2016-06-21
        • 1970-01-01
        • 2018-01-25
        • 2023-03-08
        相关资源
        最近更新 更多