简体   繁体   English

Laravel:未找到基表或视图:1146表'database.pages不存在

[英]Laravel: Base table or view not found: 1146 Table 'database.pages doesn't exist

I'm working on a CMS and I have a little problem with my migrations. 我正在使用CMS,我的迁移有点问题。 I added a new migration file and I wanted to add that one. 我添加了一个新的迁移文件,我想添加一个。 That didn't work so I ran this bit: 这没用,所以我跑了这一点:

php artisan migrate:reset

After that I ran this bit: 之后我跑了这一点:

php artisan migrate:install
php artisan migrate

And now I get this error: 现在我收到这个错误:

{"error":{"type":"Illuminate\\Database\\QueryException","message":"SQLSTATE[42S02]: Base table or 
view not found:1146 Table 'cms.pages' doesn't exist (SQL: select * from `pages`)"

The error kinda tells me that it can't find the database, because that's true. 错误有点告诉我它找不到数据库,因为那是真的。

I also have a command that runs the migrate and I run that one like this: 我还有一个运行迁移的命令,我运行这样的一个:

php artisan app:install

But that shows the same error... 但这表明同样的错误......

Remove any lines requesting data from your model from these files to be sure artisan is not trying to load data from your non-existent table: 从这些文件中删除任何从模型请求数据的行,以确保工匠不会尝试从不存在的表中加载数据:

  • bootstrap/start.php
  • app/start/global.php
  • app/start/local.php
  • app/routes.php

Also be sure to un-register any service providers that utilize data from that table in their register or boot methods inside of app/config/app.php . 还要确保取消注册在app/config/app.php内的寄存器或引导方法中使用该表中数据的任何服务提供者。


The issue is that these files not only get executed for browser (web) requests, but for all requests, including command-line artisan invocations (eg php artisan migrate ). 问题是这些文件不仅针对浏览器(web)请求执行,而且针对所有请求执行,包括命令行工匠调用(例如php artisan migrate )。 So if you try to use something before it is available in any of these files, you are going to have a Bad Time. 因此,如果您尝试在任何这些文件中使用之前使用某些内容,那么您将会遇到错误的时间。

You can use this to dictate when your app is running from the console. 您可以使用它来指示应用程序从控制台运行的时间。 I believe this issue only occurs when you run a command 我相信只有在运行命令时才会出现此问题

if( !App::runningInConsole() ){
  //allow laravel-menu to run
}

This way you will prevent data load from your non-existent table 这样,您将阻止来自不存在的表的数据加载

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel Spatie 权限 - 未找到基表或视图:1146 表“my_database.models”不存在 - Laravel Spatie Permissions - Base table or view not found: 1146 Table 'my_database.models' doesn't exist Laravel 8 - 未找到基表或视图:1146 表“laravel8.brand”不存在 - Laravel 8 - Base table or view not found: 1146 Table 'laravel8.brand' doesn't exist 未找到基表或视图:1146 表 'ifs.employees' 不存在 Laravel 错误 - Base table or view not found: 1146 Table 'ifs.employees' doesn't exist Laravel Error LARAVEL - 未找到基表或视图:1146 表不存在(SQL: select * from ) - LARAVEL - Base table or view not found: 1146 Table doesn't exist (SQL: select * from ) SQLSTATE[42S02]:未找到基表或视图:1146 表 '***.indices' 不存在 laravel - SQLSTATE[42S02]: Base table or view not found: 1146 Table '***.indices' doesn't exist laravel Laravel-[PDOException] SQLSTATE [42S02]:找不到基本表或视图:1146表'ip.priorities'不存在 - Laravel - [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ip.priorities' doesn't exist 无法在 laravel 8 上执行自动完成 - 未找到基表或视图:1146 表“workshop.nama_suppliers”不存在 - Cannot do autocomplete on laravel 8 - Base table or view not found: 1146 Table 'workshop.nama_suppliers' doesn't exist SQLSTATE [42S02]:未找到基表或视图:1146 表“laravel_abonamenty2.currencies”不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel_abonamenty2.currencies' doesn't exist SQLSTATE[42S02]: 未找到基表或视图:1146 表 'laravel9rentalcars.categories' 不存在 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel9rentalcars.categories' doesn't exist SQLSTATE[42S02]:未找到基表或视图:1146 Laravel 5.2 上不存在表“db_wls.users” - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_wls.users' doesn't exist on laravel 5.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM