Laravel:未找到基本表或视图:1146表'database.pages不存在
我正在使用CMS,但我的迁移存在一些问题.我添加了一个新的迁移文件,我想添加一个.那没有用,所以我跑了一下:
I'm working on a CMS and I have a little problem with my migrations. 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
现在我收到此错误:
{"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
-
bootstrap/start.php
-
app/start/global.php
app/start/local.php
app/routes.php
还请确保在app/config/app.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
.
问题在于,这些文件不仅会针对浏览器(web)请求执行,还会针对所有请求(包括命令行工匠调用(例如php artisan migrate
))执行.因此,如果您尝试在任何这些文件中使用某些东西之前就使用它,那么您将度过一段艰难的时光.
The issue is that these files not only get executed for browser (web) requests, but for all requests, including command-line artisan invocations (e.g. 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.