Laravel:未找到基本表或视图:1146表'database.pages不存在 [英] Laravel: Base table or view not found: 1146 Table 'database.pages doesn't exist

查看:98
本文介绍了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.

这篇关于Laravel:未找到基本表或视图:1146表'database.pages不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆