我最近从Gitlab克隆了一个Laravel项目,并在尝试php artisan migrate
时遇到错误。
错误:
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'blog.articles' doesn't exist (SQL: select count(*) as aggregate from `articles` where `published` = 1)
[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'blog.articles' doesn't exist
.ENV:
APP_ENV=local
APP_DEBUG=true
APP_KEY=UQ6ZJpBveXSQUC0q5lUzdnHb6qzwkLxo
DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=blog
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
database.php中:
'default' => env('DB_DRIVER', 'mysql'),
// . . .
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'blog'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
这个问题的原因是什么?
P.S
我正在尝试从Homestead运行项目。
编辑1
看来,依赖于表的某些代码是在迁移之前运行的。
答案 0 :(得分:0)
解决了这个问题。正如我所料,一些自定义代码正在运行before
次迁移。代码位于Providers/
,并将其评论解决了问题。