From d7287122c2a81c7da11d3856ba88f9ddc202938d Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Fri, 15 Nov 2024 11:23:29 +0000 Subject: [PATCH 1/4] Resolve native:migrate command so we can call it --- src/NativeServiceProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NativeServiceProvider.php b/src/NativeServiceProvider.php index a2d5f037..36291814 100644 --- a/src/NativeServiceProvider.php +++ b/src/NativeServiceProvider.php @@ -57,6 +57,7 @@ public function packageRegistered() $app->resolveCommands([ LoadStartupConfigurationCommand::class, LoadPHPConfigurationCommand::class, + MigrateCommand::class, ]); }); From e7cd9c638ea83d7df866220e6062834099713181 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Fri, 15 Nov 2024 11:23:56 +0000 Subject: [PATCH 2/4] Only run exception handler in native context --- src/NativeServiceProvider.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NativeServiceProvider.php b/src/NativeServiceProvider.php index 36291814..7a225418 100644 --- a/src/NativeServiceProvider.php +++ b/src/NativeServiceProvider.php @@ -47,12 +47,12 @@ public function packageRegistered() return new MigrateCommand($app['migrator'], $app['events']); }); - $this->app->singleton( - \Illuminate\Contracts\Debug\ExceptionHandler::class, - Handler::class - ); - if (config('nativephp-internal.running')) { + $this->app->singleton( + \Illuminate\Contracts\Debug\ExceptionHandler::class, + Handler::class + ); + Application::starting(function ($app) { $app->resolveCommands([ LoadStartupConfigurationCommand::class, From 0b15d4d4e7698edb83e27970e265901514479f4f Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Fri, 15 Nov 2024 11:24:15 +0000 Subject: [PATCH 3/4] Only configure DB if we have one --- src/NativeServiceProvider.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NativeServiceProvider.php b/src/NativeServiceProvider.php index 7a225418..db4519a8 100644 --- a/src/NativeServiceProvider.php +++ b/src/NativeServiceProvider.php @@ -128,8 +128,10 @@ public function rewriteDatabase() config(['database.default' => 'nativephp']); - DB::statement('PRAGMA journal_mode=WAL;'); - DB::statement('PRAGMA busy_timeout=5000;'); + if (file_exists($databasePath)) { + DB::statement('PRAGMA journal_mode=WAL;'); + DB::statement('PRAGMA busy_timeout=5000;'); + } } public function removeDatabase() From 563345bd61e0744d3ccc0a808f5055b43ffbfd9e Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Fri, 15 Nov 2024 11:24:47 +0000 Subject: [PATCH 4/4] Silently unlink all SQlite files --- src/NativeServiceProvider.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/NativeServiceProvider.php b/src/NativeServiceProvider.php index db4519a8..d9c28a1f 100644 --- a/src/NativeServiceProvider.php +++ b/src/NativeServiceProvider.php @@ -140,13 +140,11 @@ public function removeDatabase() if (config('app.debug')) { $databasePath = database_path('nativephp.sqlite'); - - if (! file_exists($databasePath)) { - return; - } } - unlink($databasePath); + @unlink($databasePath); + @unlink($databasePath.'-shm'); + @unlink($database.'-wal'); } protected function configureDisks(): void