File tree 2 files changed +25
-5
lines changed
2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 3
3
namespace Native \Laravel \Commands ;
4
4
5
5
use Illuminate \Console \Command ;
6
+ use Illuminate \Database \Console \Migrations \FreshCommand as BaseFreshCommand ;
6
7
use Native \Laravel \NativeServiceProvider ;
7
8
8
- class FreshCommand extends Command
9
+ class FreshCommand extends BaseFreshCommand
9
10
{
10
- protected $ description = 'Run the database migrations in the NativePHP development environment ' ;
11
+ protected $ description = 'Drop all tables and re-run all migrations in the NativePHP development environment ' ;
11
12
12
- protected $ signature = 'native:migrate fresh ' ;
13
+ protected $ signature = 'native:migrate: fresh ' ;
13
14
14
15
public function handle ()
15
16
{
16
- unlink ( config ( ' nativephp-internal.database_path ' ) );
17
+ $ nativeServiceProvider = new NativeServiceProvider ( $ this -> laravel );
17
18
18
- (new NativeServiceProvider ($ this ->laravel ))->rewriteDatabase ();
19
+ $ nativeServiceProvider ->removeDatabase ();
20
+
21
+ $ nativeServiceProvider ->rewriteDatabase ();
19
22
20
23
$ this ->call ('native:migrate ' );
21
24
}
Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Console \Application as Artisan ;
6
6
use Illuminate \Support \Arr ;
7
+ use Native \Laravel \Commands \FreshCommand ;
7
8
use Native \Laravel \Commands \LoadPHPConfigurationCommand ;
8
9
use Native \Laravel \Commands \LoadStartupConfigurationCommand ;
9
10
use Native \Laravel \Commands \MigrateCommand ;
@@ -21,6 +22,7 @@ public function configurePackage(Package $package): void
21
22
->name ('nativephp ' )
22
23
->hasCommands ([
23
24
MigrateCommand::class,
25
+ FreshCommand::class,
24
26
SeedDatabaseCommand::class,
25
27
MinifyApplicationCommand::class,
26
28
])
@@ -109,6 +111,21 @@ public function rewriteDatabase()
109
111
config (['database.default ' => 'nativephp ' ]);
110
112
}
111
113
114
+ public function removeDatabase ()
115
+ {
116
+ $ databasePath = config ('nativephp-internal.database_path ' );
117
+
118
+ if (config ('app.debug ' )) {
119
+ $ databasePath = database_path ('nativephp.sqlite ' );
120
+
121
+ if (! file_exists ($ databasePath )) {
122
+ return ;
123
+ }
124
+ }
125
+
126
+ unlink ($ databasePath );
127
+ }
128
+
112
129
protected function configureDisks (): void
113
130
{
114
131
$ disks = [
You can’t perform that action at this time.
0 commit comments