Skip to content

Commit b7316b3

Browse files
committed
docs: reworks docs
1 parent f071d05 commit b7316b3

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

README.md

+30-21
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,39 @@
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.
13+
> This package is a work-in-progress, therefore you should not use it in production - and **always** backup your database before requiring it through Composer.
14+
>
15+
> - [Migration Stub](https://github.com/nunomaduro/laravel-optimize-database/blob/main/database/migrations/optimize_database_settings.php.stub)
16+
> - [Runtime Configuration](https://github.com/nunomaduro/laravel-optimize-database/blob/main/src/OptimizeDatabaseServiceProvider.php)
1417
15-
This package publish a migration that will apply good defaults to your SQLite database, making it faster and more production-ready.
18+
This package provides a simple way to optimize your SQLite database in Laravel; it's a good starting point for production-ready SQLite databases. At the time of this writing,
19+
it applies the following settings:
1620

17-
> **Requires [PHP 8.2+](https://php.net/releases), [SQLite 3.46+](https://www.sqlite.org/changes.html) and [Laravel 11.0+](https://laravel.com)**
21+
```
22+
┌───────────────────────────┬─────────────┬───────────┐
23+
│ Setting │ Value │ Via │
24+
├───────────────────────────┼─────────────┼───────────┤
25+
│ PRAGMA auto_vacuum │ incremental │ Migration │
26+
│ PRAGMA journal_mode │ WAL │ Migration │
27+
│ PRAGMA page_size │ 32768 │ Migration │
28+
│ PRAGMA busy_timeout │ 5000 │ Runtime │
29+
│ PRAGMA cache_size │ -20000 │ Runtime │
30+
│ PRAGMA foreign_keys │ ON │ Runtime │
31+
│ PRAGMA incremental_vacuum │ (enabled) │ Runtime │
32+
│ PRAGMA mmap_size │ 2147483648 │ Runtime │
33+
│ PRAGMA temp_store │ MEMORY │ Runtime │
34+
│ PRAGMA synchronous │ NORMAL │ Runtime │
35+
└───────────────────────────┴─────────────┴───────────┘
36+
```
37+
38+
The settings are applied in two ways:
39+
- [Migration] - Applied via migration.
40+
- [Runtime] - Applied at runtime, via service provider.
1841

1942
## 🚀 Installation
2043

44+
> **Requires [PHP 8.2+](https://php.net/releases), [SQLite 3.46+](https://www.sqlite.org/changes.html) and [Laravel 11.0+](https://laravel.com)**
45+
2146
You can install the package via [Composer](https://getcomposer.org):
2247

2348
```bash
@@ -26,29 +51,13 @@ composer require nunomaduro/laravel-optimize-database --dev
2651

2752
## 🙌 Usage
2853

29-
To optimize your SQLite database, you need to run the migration that this package provides:
54+
To get starter optimizing your SQLite database, you need to run the following command:
3055

3156
```bash
3257
php artisan db:optimize
3358
```
3459

35-
This will publish a migration that apply defaults like so:
36-
37-
```SQL
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-
}
49-
```
50-
51-
Next, you simply need to run the migration:
60+
At this point, the [Runtime] settings are applied automatically. However, you need to run the migration to apply the [Migration] settings:
5261

5362
```bash
5463
php artisan migrate

0 commit comments

Comments
 (0)