QueryException:找不到SQLSTATE[42S02]基表或视图



所以我在尝试从github repo运行laravel时出错。上面写着SQLSTATE[42502],我试图通过寻找相同的主题来解决,但仍然,卷土重来。

时间顺序如下所示

  1. 我从github中提取了一个存储库
  2. 我运行composer更新,供应商文件夹中的所有软件包都开始逐一安装
  3. 直到它尝试生成最佳的自动加载并出现错误

BTW我只有数据库迁移文件,没有.SQL文件。

所以,如果你们中有人能帮忙,我真的很感激。谢谢

IlluminateDatabaseQueryException  : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.product_requests' doesn't exist (SQL: select count(*) as aggregate from `product_requests` where `read_at` is null)
at C:xampphtdocsayoreview-mastervendorlaravelframeworksrcIlluminateDatabaseConnection.php:669
665|         // If an exception occurs when attempting to run a query, we'll format the error
666|         // message to include the bindings with SQL, which will make this exception a
667|         // lot more helpful to the developer instead of just the database's errors.
668|         catch (Exception $e) {
> 669|             throw new QueryException(
670|                 $query, $this->prepareBindings($bindings), $e
671|             );
672|         }
673|
Exception trace:
1   IlluminateFoundationApplication::IlluminateFoundation{closure}(Object(AppProvidersAppServiceProvider))
[internal]:0
2   DoctrineDBALDriverPDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.product_requests' doesn't exist")
C:xampphtdocsayoreview-mastervendordoctrinedballibDoctrineDBALDriverPDOConnection.php:66

我的product_requests的相关迁移文件

<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
class CreateProductRequestsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_requests', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->text('specification');
$table->bigInteger('price');
$table->string('link');
$table->string('featured_image');
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('brand_id')->nullable();
$table->text('description')->nullable();
$table->dateTime('read_at')->nullable();
$table->dateTime('exported_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_requests');
}
}

更多详细信息

应用服务提供商

<?php
namespace AppProviders;
use AppProductRequest;
use IlluminatePaginationPaginator;
use IlluminateSupportFacadesConfig;
use IlluminateSupportFacadesURL;
use IlluminateSupportServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
if(Config::get('app.redirect_https')) {
URL::forceScheme('https');
}
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if(Config::get('app.redirect_https')) {
$this->app['request']->server->set('HTTPS', true);
}
Paginator::defaultView('custom.pagination');
$unreadRequestedProduct = ProductRequest::whereNull('read_at')->count();
session()->flash('product_request', $unreadRequestedProduct);
}
}

编写器更新时的完全跟踪

C:xampphtdocsayoreview-master>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating laravel/framework (v6.18.31 => v6.18.32): Downloading (100%)
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Writing lock file
Generating optimized autoload files
Deprecation Notice: Class GuzzleTestsCommonCacheNullCacheAdapterTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsCacheNullCacheAdapterTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsCommonAbstractHasAdapterTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsCommonAbstractHasDispatcherTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsMessageHeaderComparisonTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpMessageHeaderComparisonTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsHttpMessageHttpRequestFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpMessageRequestFactoryTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsMessageResponseTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpMessageResponseTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsHttpCommaAggregatorTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpQueryAggregatorCommaAggregatorTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsHttpDuplicateAggregatorTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpQueryAggregatorDuplicateAggregatorTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsHttpPhpAggregatorTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpQueryAggregatorPhpAggregatorTest.php
does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsPluginRedirectRedirectPluginTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpRedirectPluginTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsPluginRedirectStaticClientTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsHttpStaticClientTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsParsersUriTemplateAbstractUriTemplateTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsParserUriTemplateAbstractUriTemplateTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsParsersUriTemplatePeclUriTemplateTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsParserUriTemplatePeclUriTemplateTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsParsersUriTemplateUriTemplateTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsParserUriTemplateUriTemplateTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceServiceBuilderTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceBuilderServiceBuilderTest.php
does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceCommandAliasFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceCommandFactoryAliasFactoryTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceCommandCompositeFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceCommandFactoryCompositeFactoryTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceCommandConcreteClassFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceCommandFactoryConcreteClassFactoryTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceCommandMapFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceCommandFactoryMapFactoryTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceCommandServiceDescriptionFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceCommandFactoryServiceDescriptionFactoryTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class GuzzleTestsServiceCommandVisitorFlyweightTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/testsGuzzleTestsServiceCommandLocationVisitorVisitorFlyweightTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
IlluminateDatabaseQueryException  : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.product_requests' doesn't exist (SQL: select count(*) as aggregate from `product_requests` where `read_at` is null)
at C:xampphtdocsayoreview-mastervendorlaravelframeworksrcIlluminateDatabaseConnection.php:669
665|         // If an exception occurs when attempting to run a query, we'll format the error
666|         // message to include the bindings with SQL, which will make this exception a
667|         // lot more helpful to the developer instead of just the database's errors.
668|         catch (Exception $e) {
> 669|             throw new QueryException(
670|                 $query, $this->prepareBindings($bindings), $e
671|             );
672|         }
673|
Exception trace:
1   IlluminateFoundationApplication::IlluminateFoundation{closure}(Object(AppProvidersAppServiceProvider))
[internal]:0
2   DoctrineDBALDriverPDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.product_requests' doesn't exist")
C:xampphtdocsayoreview-mastervendordoctrinedballibDoctrineDBALDriverPDOConnection.php:66
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Composer.json

{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"ext-gd": "*",
"ext-imagick": "*",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0",
"intervention/image": "^2.5",
"laravel/framework": "^6.2",
"laravel/sanctum": "^2.3",
"laravel/socialite": "^4.4",
"laravel/tinker": "^2.0",
"league/flysystem-aws-s3-v3": "~1.0",
"santigarcor/laratrust": "^6.0",
"yajra/laravel-datatables-oracle": "~9.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.3",
"barryvdh/laravel-ide-helper": "^2.7",
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.9.1",
"laravel/ui": "^1.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0",
"spatie/laravel-web-tinker": "^1.7"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\": "app/"
},
"files": [
"app/Helpers/helper.php"
],
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r "file_exists('.env') || copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate"
]
}
}

好吧,伙计们,我想我通过尝试先强制迁移,然后再进行composer更新来解决这个问题。你们是对的,这可能是由于启动时的错误导致的,所以它推迟了迁移过程。所以我只是创建一个新的laravel文件夹,并在那里进行新的迁移。

这是我一步一步

1. create new laravel folder
2. copy & paste database folder from the original repo
3. do migrate
- if " Error
Class 'DoctrineDBALDriverPDOMySqlDriver' not found
- do composer require doctrine/dbal
4. continue migrate again   
5. copy & paste all the rest of folder & file from the original repo
6. composer install

完成

感谢您的所有评论

相关内容

最新更新