gpt4 book ai didi

mysql - 找不到基表或 View : 1146 Table 'prj_oxbir.permissions' doesn't exist

转载 作者:行者123 更新时间:2023-11-29 07:37:58 26 4
gpt4 key购买 nike

权限文件确实存在于文件夹中。为什么显示此错误。

In Connection.php line 647:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'prj_oxbir.permissions' doesn't exist (SQL: select * from permissions)

In Connection.php line 319:

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

createrolestable.php

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

class CreateRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
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']);
});
}

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

最佳答案

首先,确保数据库中存在表权限

其次,为 permissions 表创建一个单独的迁移。

希望这对您有所帮助。

关于mysql - 找不到基表或 View : 1146 Table 'prj_oxbir.permissions' doesn't exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47864452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com