gpt4 book ai didi

php - 如何修复运行 "Base table or view not found: 1146"命令时出现 'php artisan migrate' 错误?

转载 作者:可可西里 更新时间:2023-10-31 23:07:55 26 4
gpt4 key购买 nike

我正在尝试朗姆酒 php artisan migrate 来生成表迁移,但我收到一个错误:

[2016-03-08 05:49:01] local.ERROR: exception 'PDOException' withmessage 'SQLSTATE[42S02]: Base table or view not found: 1146 Table'testing.permissions' doesn't exist' inD:\xampp\htdocs\LMS-testing\vendor\laravel\framework\src\Illuminate\Database\Connection.php:333

我试过了Base table or view not found: 1146 Table Laravel 5Doing a Laravel tutorial, getting "Base table or view not found: 1146 Table 'sdbd_todo.migrations' doesn't exist"但没有成功。

我也试过运行 php artisan list 但得到了同样的错误。

已更新

**RolesPermission migration table**

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

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

Schema::create('permission_role', function(Blueprint $table){
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();

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

$table->foreign('role_id')
->references('id')
->on('roles')
->onDelete('cascade');

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

Schema::create('role_user', function(Blueprint $table){
$table->integer('role_id')->unsigned();
$table->integer('user_id')->unsigned();

$table->foreign('role_id')
->references('id')
->on('roles')
->onDelete('cascade');

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

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

});


.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=W8YWZe3LCngvZzexH3WLWqCDlYRSufuy

DB_HOST=127.0.0.1
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

最佳答案

检查你的迁移文件,也许你正在使用 Schema::table,像这样:

Schema::table('table_name', function ($table)  {
// ...
});

如果你想创建一个新表你必须使用 Schema::create:

Schema::create('table_name', function ($table)  {
// ...
});

Laracast More information in this link .

关于php - 如何修复运行 "Base table or view not found: 1146"命令时出现 'php artisan migrate' 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35860280/

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