queryexception:找不到sqlstate[42s02]基表或视图

vdgimpew  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(384)

因此,我在尝试从github repo运行laravel时出错。它说的是sqlstate[42502],我试图通过寻找相同的主题来解决这个问题,但是,复出仍然卡住了。
时间顺序很简单
我从github中提取了一个存储库
我运行了composer更新,供应商文件夹中的所有软件包都开始逐一安装
直到它试图生成最佳的自动加载和错误出现
顺便说一句,我只有数据库迁移文件,没有.sql文件。
所以如果你们中有人能帮忙,我真的很感激。谢谢

Illuminate\Database\QueryException  : 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:\xampp\htdocs\ayoreview-master\vendor\laravel\framework\src\Illuminate\Database\Connection.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   Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider))
      [internal]:0

  2   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.product_requests' doesn't exist")
      C:\xampp\htdocs\ayoreview-master\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:66

我的产品请求的相关迁移文件

<?php

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

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 App\Providers;

use App\ProductRequest;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

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:\xampp\htdocs\ayoreview-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 Guzzle\Tests\Common\Cache\NullCacheAdapterTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Cache\NullCacheAdapterTest.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 Guzzle\Tests\Common\AbstractHasAdapterTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Common\AbstractHasDispatcherTest.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 Guzzle\Tests\Message\HeaderComparisonTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\Message\HeaderComparisonTest.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 Guzzle\Tests\Http\Message\HttpRequestFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\Message\RequestFactoryTest.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 Guzzle\Tests\Message\ResponseTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\Message\ResponseTest.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 Guzzle\Tests\Http\CommaAggregatorTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\QueryAggregator\CommaAggregatorTest.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 Guzzle\Tests\Http\DuplicateAggregatorTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\QueryAggregator\DuplicateAggregatorTest.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 Guzzle\Tests\Http\PhpAggregatorTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\QueryAggregator\PhpAggregatorTest.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 Guzzle\Tests\Plugin\Redirect\RedirectPluginTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\RedirectPluginTest.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 Guzzle\Tests\Plugin\Redirect\StaticClientTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Http\StaticClientTest.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 Guzzle\Tests\Parsers\UriTemplate\AbstractUriTemplateTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Parser\UriTemplate\AbstractUriTemplateTest.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 Guzzle\Tests\Parsers\UriTemplate\PeclUriTemplateTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Parser\UriTemplate\PeclUriTemplateTest.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 Guzzle\Tests\Parsers\UriTemplate\UriTemplateTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Parser\UriTemplate\UriTemplateTest.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 Guzzle\Tests\Service\ServiceBuilderTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Builder\ServiceBuilderTest.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 Guzzle\Tests\Service\Command\AliasFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Command\Factory\AliasFactoryTest.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 Guzzle\Tests\Service\Command\CompositeFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Command\Factory\CompositeFactoryTest.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 Guzzle\Tests\Service\Command\ConcreteClassFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Command\Factory\ConcreteClassFactoryTest.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 Guzzle\Tests\Service\Command\MapFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Command\Factory\MapFactoryTest.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 Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Command\Factory\ServiceDescriptionFactoryTest.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 Guzzle\Tests\Service\Command\VisitorFlyweightTest located in C:/xampp/htdocs/ayoreview-master/vendor/guzzle/guzzle/tests\Guzzle\Tests\Service\Command\LocationVisitor\VisitorFlyweightTest.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
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Illuminate\Database\QueryException  : 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:\xampp\htdocs\ayoreview-master\vendor\laravel\framework\src\Illuminate\Database\Connection.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   Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider))
      [internal]:0

  2   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.product_requests' doesn't exist")
      C:\xampp\htdocs\ayoreview-master\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.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

编写器.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"
        ]
    }
}
cs7cruho

cs7cruho1#

好了,伙计们,我想我已经解决了这个问题,我试着先强制迁移,然后再更新 composer 。你们是对的,可能是因为启动时的错误,所以推迟了迁移过程。所以我只需要创建一个新的fresh laravel文件夹并在那里进行迁移。
这是我的一步一步

1. create new laravel folder
2. copy & paste database folder from the original repo
3. do migrate
    - if " Error
  Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' 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

完成
谢谢你的评论

相关问题