Skip to content

feat: add WipeDatabaseCommand for database management #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Commands/WipeDatabaseCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Native\Laravel\Commands;

use Illuminate\Database\Console\WipeCommand as BaseWipeCommand;
use Native\Laravel\NativeServiceProvider;

class WipeDatabaseCommand extends BaseWipeCommand
{
protected $name = 'native:db:wipe';

protected $description = 'Wipe the database in the NativePHP development environment';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"In the development environment" - should this have a check for app()->isLocal()?

Could allow the --force flag if someone intends to use in production for safety?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have thought that this check should be handled with the DB::prohibitDestructiveCommands() function.

https://laravel-news.com/prevent-destructive-commands-from-running-in-laravel-11


public function handle()
{
(new NativeServiceProvider($this->laravel))->rewriteDatabase();

return parent::handle();
}
}
2 changes: 2 additions & 0 deletions src/NativeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
use Native\Laravel\Commands\LoadStartupConfigurationCommand;
use Native\Laravel\Commands\MigrateCommand;
use Native\Laravel\Commands\SeedDatabaseCommand;
use Native\Laravel\Commands\WipeDatabaseCommand;
use Native\Laravel\Contracts\ChildProcess as ChildProcessContract;
use Native\Laravel\Contracts\GlobalShortcut as GlobalShortcutContract;
use Native\Laravel\Contracts\PowerMonitor as PowerMonitorContract;
@@ -42,6 +43,7 @@ public function configurePackage(Package $package): void
FreshCommand::class,
MigrateCommand::class,
SeedDatabaseCommand::class,
WipeDatabaseCommand::class,
])
->hasConfigFile()
->hasRoute('api')
Loading
Oops, something went wrong.