我在Laravel 8中创建了Laravel安装向导,但是当我运行
Artisan::call('migrate', ['--force' => true])当我执行代码时,我收到了以下消息
SQLSTATE42000:语法错误或访问冲突: 1103不正确的表名'‘(SQL:创建表 (
idint无符号非空auto_increment主键,migrationvarchar(191) null,batchint null)默认字符集utf8mb4排序规则'utf8mb4_unicode_ci')
我尝试过使用php artisan migrate运行迁移,它运行得很好。我认为问题在于创建migrations表时,因为我没有任何带有migration和batch字段的表
这是我的migrate()函数
public function migrate()
{
try {
Artisan::call('migrate', ['--force' => true]);
} catch (\Throwable $th) {
return $this->response(
"Failed to migrate tables. ".$th->getMessage(),
'error'
);
}
return $this->seed();
}这是我的seed()函数
public function seed()
{
try {
Artisan::call('db:seed', ['--force' => true]);
} catch (\Throwable $th) {
return $this->response(
"Failed to seed tables. ".$th->getMessage(),
'error'
);
}
return $this->response(
"Successfully migrated and seeded tables.",
'success'
);
}发布于 2021-03-21 18:56:56
手工命令相对于您的代码所在的文件夹。因此,如果您不在应用程序的根文件夹中,则必须指定到迁移文件夹的路径。
Artisan::call('migrate', array('--path' => '../app/database/migrations'));https://stackoverflow.com/questions/66525616
复制相似问题