Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 2.61 KB

README.md

File metadata and controls

57 lines (41 loc) · 2.61 KB

Skeleton Php

GitHub Workflow Status (main) Total Downloads Latest Version License


This package is a work-in-progress, and the goal is to keep improving the migration stub: database/migrations/optimize_database_settings.php.stub. At the moment, it only supports SQLite, but I am open to adding support for other database types.

This package publish a migration that will apply good defaults to your SQLite database, making it faster and more production-ready.

Requires PHP 8.2+, SQLite 3.46+ and Laravel 11.0+

🚀 Installation

You can install the package via Composer:

composer require nunomaduro/laravel-optimize-database --dev

🙌 Usage

To optimize your SQLite database, you need to run the migration that this package provides:

php artisan db:optimize

This will publish a migration that apply defaults like so:

    public function up(): void
    {
        DB::statement('PRAGMA journal_mode = WAL');
        DB::statement('PRAGMA synchronous = NORMAL');
        DB::statement('PRAGMA page_size = 32768;');
        DB::statement('PRAGMA cache_size = -20000;');
        DB::statement('PRAGMA auto_vacuum = incremental;');
        DB::statement('PRAGMA foreign_keys = ON;');

        // etc...
    }

Next, you simply need to run the migration:

php artisan migrate

Laravel Optimize Database was created by Nuno Maduro under the MIT license.