Skip to content

Commit d122058

Browse files
committed
Merge branch 'main' of github.com:nunomaduro/laravel-optimize-database
2 parents b6e3bab + 7669745 commit d122058

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
------
1212

13+
> This package is a work-in-progress, and the goal is to keep improving the migration stub: [database/migrations/optimize_database_settings.php.stub](https://github.com/nunomaduro/laravel-optimize-database/blob/main/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.
14+
1315
This package publish a migration that will apply good defaults to your SQLite database, making it faster and more production-ready.
1416

1517
> **Requires [PHP 8.2+](https://php.net/releases), [SQLite 3.46+](https://www.sqlite.org/changes.html) and [Laravel 11.0+](https://laravel.com)**
@@ -33,12 +35,17 @@ php artisan db:optimize
3335
This will publish a migration that apply defaults like so:
3436

3537
```SQL
36-
PRAGMA journal_mode = WAL;
37-
PRAGMA synchronous = NORMAL;
38-
PRAGMA page_size = 32768;
39-
PRAGMA cache_size = -20000;
40-
PRAGMA auto_vacuum = incremental;
41-
// etc...
38+
public function up(): void
39+
{
40+
DB::statement('PRAGMA journal_mode = WAL');
41+
DB::statement('PRAGMA synchronous = NORMAL');
42+
DB::statement('PRAGMA page_size = 32768;');
43+
DB::statement('PRAGMA cache_size = -20000;');
44+
DB::statement('PRAGMA auto_vacuum = incremental;');
45+
DB::statement('PRAGMA foreign_keys = ON;');
46+
47+
// etc...
48+
}
4249
```
4350

4451
Next, you simply need to run the migration:

database/migrations/optimize_database_settings.php.stub

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ return new class extends Migration
1616
DB::statement('PRAGMA page_size = 32768;');
1717
DB::statement('PRAGMA cache_size = -20000;');
1818
DB::statement('PRAGMA auto_vacuum = incremental;');
19+
DB::statement('PRAGMA foreign_keys = ON;');
1920
}
2021
}
2122
};

0 commit comments

Comments
 (0)