[英]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.