Skip to content

Commit

Permalink
Feat: Move non-persistent pragmas to AppServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
nikspyratos committed Apr 22, 2024
1 parent d9efd24 commit 413f90b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
21 changes: 20 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
Expand All @@ -29,7 +30,7 @@ class AppServiceProvider extends ServiceProvider
#[Override]
public function register(): void
{
// Stub
$this->bootDatabase();
}

/**
Expand All @@ -48,6 +49,24 @@ public function boot(): void
$this->bootRoute();
}

public function bootDatabase(): void
{
$connections = ['sqlite', 'cache_db', 'pulse_db', 'queue_db', 'telescope_db'];
foreach ($connections as $connection) {
DB::connection($connection)
->statement(
'
PRAGMA synchronous = NORMAL;
PRAGMA mmap_size = 134217728; -- 128 megabytes
PRAGMA cache_size = 1000000000;
PRAGMA foreign_keys = true;
PRAGMA busy_timeout = 5000;
PRAGMA temp_store = memory;
'
);
}
}

public function bootAuth(): void
{
$isAdminCallback = static fn (User $user) => $user->is_admin;
Expand Down
7 changes: 0 additions & 7 deletions database/migrations/2014_10_11_000000_init_sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ public function up(): void
->statement(
'
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA journal_size_limit = 67108864; -- 64 megabytes
PRAGMA mmap_size = 134217728; -- 128 megabytes
PRAGMA cache_size = 1000000000;
PRAGMA foreign_keys = true;
PRAGMA busy_timeout = 5000;
PRAGMA temp_store = memory;
COMMIT;
'
);
Expand Down

0 comments on commit 413f90b

Please sign in to comment.