@@ -31,20 +31,63 @@ keeping download & install size small.
31
31
32
32
You do not need to do anything special to configure your application to use SQLite. NativePHP will automatically:
33
33
- Switch to using SQLite when building your application
34
- - Create a database file for you in the ` storage ` directory on the user's system
34
+ - Create a database file for you in the ` appdata ` directory on the user's system
35
35
- Configure your application to use that database file
36
- - Run your migrations each time your app starts if needed
36
+ - Run your migrations each time your app starts, as needed
37
+
38
+ ## Development
39
+
40
+ Remember that in [ development] ( /docs/getting-started/development ) your application's database is always going to be
41
+ the SQLite database created in the ` appdata ` folder for your application.
42
+
43
+ This means that even if you've got different config in your ` .env ` file, your application will not be connecting to any
44
+ other database when it is running within the Electron/Tauri environment.
37
45
38
46
## Migrations
39
47
40
48
When writing migrations, you need to consider any special recommendations for working with SQLite. For example,
41
49
SQLite disables foreign key constraints by default. If your application relies upon foreign key constraints,
42
- [ you need to enable SQLite support for them] ( https://laravel.com/docs/10.x/ database#configuration ) before
50
+ [ you need to enable SQLite support for them] ( https://laravel.com/docs/database#configuration ) before
43
51
writing your migrations.
44
52
45
53
** It's important to test your migrations before releasing updates!** You don't want to accidentally delete your user's
46
54
data when they update your app.
47
55
56
+ ### Running migrations
57
+
58
+ NativePHP will attempt to migrate your database on each boot-up.
59
+
60
+ You may also wish to manually migrate it during development, either while the application is already running or without
61
+ booting the application.
62
+
63
+ You can do this with the ` native:migrate ` command:
64
+
65
+ ``` shell
66
+ php artisan native:migrate
67
+ ```
68
+
69
+ This command uses the exact same signature as the Laravel ` migrate ` command, so everything you're used to there can be
70
+ used here.
71
+
72
+ ### Refreshing your app database
73
+
74
+ You can completely refresh your app database using the ` native:migrate fresh ` command:
75
+
76
+ ``` shell
77
+ php artisan native:migrate fresh
78
+ ```
79
+
80
+ ** This is a destructive action that will delete all data in your database.**
81
+
82
+ ## Seeding
83
+
84
+ When developing, it's especially useful to seed your database with sample data. If you've set up
85
+ [ Database Seeders] ( https://laravel.com/docs/seeding ) , you can run these using the ` native:db:seed ` command:
86
+
87
+ ``` shell
88
+ php artisan native:db:seed
89
+ ```
90
+
48
91
## When not to use a database
49
92
50
93
If you're only storing small amounts of very simple metadata or working files, you may not need a database at all.
0 commit comments