Laravel 通过代码运行 'migrate:fresh' 返回会话错误

我正在使用这个函数来创建一个新的数据库表

public function new_migration(){

        if(App::environment('demo')){
            try {
                
                Artisan::call('cache:clear');
                Artisan::call('route:clear');
                Artisan::call('config:clear');
                Artisan::call('view:clear');
                Artisan::call('migrate:fresh',[
                    '--seed' => true,]);

                echo 'New migrations done!';

            } catch (Exception $e) {
                Response::make($e->getMessage(),500);
            }
        }else{
            App::abort(404);
        } 
}

抛出这个错误

Illuminate\Database\QueryException SQLSTATE[42S02]:未找到基表或视图:1146 表 'database.sessions' 不存在(SQL:select * from sessions where id = ThDv1nWU3nFgNizz7gpqOYAUkxe9O2olFUjtBXE1 limit 1)

我使用数据库作为会话驱动程序

SESSION_DRIVER=database
SESSION_LIFETIME=120

运行

php artisan migrate:fresh --seed 

直接在命令行上运行得很好

pfa 截图

Laravel 通过代码运行 'migrate:fresh' 返回会话错误

sd529 回答:Laravel 通过代码运行 'migrate:fresh' 返回会话错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/501513.html

大家都在问