warn('pdo_sqlite fehlt – der Prozess-Tester bleibt gesperrt.'); return self::SUCCESS; } $directory = storage_path('app/sandbox'); @mkdir($directory.'/runs', 0775, true); $file = $directory.'/template.building.sqlite'; @unlink($file); touch($file); config(['database.connections.sandbox_template' => ['driver' => 'sqlite', 'database' => $file, 'prefix' => '', 'foreign_key_constraints' => true]]); // `migrate --database` switches the default connection of this process and does not switch it back. $default = DB::getDefaultConnection(); try { Artisan::call('migrate', ['--database' => 'sandbox_template', '--force' => true, '--no-interaction' => true]); } finally { DB::setDefaultConnection($default); DB::purge('sandbox_template'); config(['database.connections.sandbox_template' => null]); } rename($file, $directory.'/template.sqlite'); $this->info('Vorlage erstellt: '.$directory.'/template.sqlite'); return self::SUCCESS; } }