【发布时间】:2021-06-06 02:04:09
【问题描述】:
我正在 Laravel 8 中创建 Laravel 安装向导,但运行时出现问题
Artisan::call('migrate', ['--force' => true])
当我执行代码时,我收到了这条消息
SQLSTATE[42000]: 语法错误或访问冲突: 1103 Incorrect table name '' (SQL: create table `` (
idint unsigned not null auto_increment 主键,migrationvarchar(191) not null, @ 987654324@ int not null) 默认字符集 utf8mb4 collate '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'
);
}
【问题讨论】:
-
检查你的迁移文件夹是否有没有表名的文件
-
@Doggo 没有,没有没有表名的文件
-
尝试在您的
config -> database.php中添加'migrations' => 'migrations' -
已经存在
-
您是否尝试运行
php artisan config:cache?