简体   繁体   English

SQLSTATE [42S02]:找不到基表或视图:1146表'prj_roocket.permissions'不存在

[英]SQLSTATE[42S02]: Base table or view not found: 1146 Table 'prj_roocket.permissions' doesn't exist

I create a migration 我创建一个迁移

Schema::create('roles', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('label')->nullable();
        $table->timestamps();
    });

    Schema::create('permissions', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('label')->nullable();
        $table->timestamps();
    });

    Schema::create('permission_role', function (Blueprint $table) {
        $table->integer('role_id')->unsigned();
        $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');

        $table->integer('permission_id')->unsigned();
        $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');

        $table->primary(['role_id' , 'permission_id']);
    });

    Schema::create('role_user', function (Blueprint $table) {
        $table->integer('role_id')->unsigned();
        $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');

        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

        $table->primary(['role_id' , 'user_id']);
    });

Any what I write in CMD php artisan migrate and composer dumpautoload and php artisan serve and... This error is seen. 我在CMD中编写的任何php artisan migrate and composer dumpautoload and php artisan serve and...看到此错误。 and too I deleted database and I create a new database. 我也删除了数据库,然后创建了一个新数据库。

[Illuminate\\Database\\QueryException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'prj_roocket.permissions' doesn't exist (SQL: select * from permissions ) [Illuminate \\ Database \\ QueryException] SQLSTATE [42S02]:未找到基表或视图:1146表'prj_roocket.permissions'不存在(SQL:从permissions选择*)

[PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'prj_roocket.permissions' doesn't exist [PDOException] SQLSTATE [42S02]:找不到基表或视图:1146表'prj_roocket.permissions'不存在

This error is given by the function getPermissions in AuthServiceProvider (or somewhere else you defined your authentication service provider). 该错误由AuthServiceProvider中的 getPermissions函数(或您定义的身份验证服务提供程序的其他地方)给出。

Probabily your function looks like this: 可能您的函数如下所示:

protected function getPermissions()
{
    return Permission::with('roles')->get();
}

Try to replace the function getPermissions with: 尝试将功能getPermissions替换为:

protected function getPermissions()
{
    try {
        return Permission::with('roles')->get();
    } catch (\Exception $e) {
        return [];
    }
}

and then run php artisan migrate again. 然后再次运行php artisan迁移

Note: with this fix you are not going to compromise the system security. 注意:使用此修复程序,您将不会损害系统安全性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQLSTATE [42S02]:未找到基表或视图:1146表X不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table X doesn't exist SQLSTATE[42S02]:未找到基表或视图:1146 表 '***.indices' 不存在 laravel - SQLSTATE[42S02]: Base table or view not found: 1146 Table '***.indices' doesn't exist laravel Laravel-[PDOException] SQLSTATE [42S02]:找不到基本表或视图:1146表'ip.priorities'不存在 - Laravel - [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ip.priorities' doesn't exist SQLSTATE [42S02]:找不到基表或视图:1146表'docgenerator.curricula'不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'docgenerator.curricula' doesn't exist SQLSTATE[42S02]:未找到基表或视图:1146 表 'moltens.slider' 不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'moltens.sliders' doesn't exist SQLSTATE [42S02]:未找到基表或视图:1146 表 'sathish_company.clients' 不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sathish_company.clients' doesn't exist SQLSTATE [42S02]:找不到基表或视图:1146表'sf_sandbox.phpcr_workspaces'不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sf_sandbox.phpcr_workspaces' doesn't exist SQLSTATE[42S02]:未找到基表或视图:1146 表“My_database_Name.posts”不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'My_database_Name.posts' doesn't exist SQLSTATE[42S02]:未找到基表或视图:1146 表 'hr.staff' 不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'hr.staff' doesn't exist SQLSTATE [42S02]:未找到基表或视图:1146 表“laravel_abonamenty2.currencies”不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel_abonamenty2.currencies' doesn't exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM