Skip to content

Commit

Permalink
[11.x] Prevent destructive commands from running (#51376)
Browse files Browse the repository at this point in the history
* Prevent destructive commands from running

* Test cleanup

* formatting

* add consolidated method

* Update DB.php

* pass through

* rename param

* Update Prohibitable.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
jasonmccreary and taylorotwell authored May 21, 2024
1 parent 8deb8ba commit a39aca5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Facades/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Illuminate\Support\Facades;

use Illuminate\Database\Console\Migrations\FreshCommand;
use Illuminate\Database\Console\Migrations\RefreshCommand;
use Illuminate\Database\Console\Migrations\ResetCommand;
use Illuminate\Database\Console\WipeCommand;

/**
* @method static \Illuminate\Database\Connection connection(string|null $name = null)
* @method static \Illuminate\Database\ConnectionInterface connectUsing(string $name, array $config, bool $force = false)
Expand Down Expand Up @@ -109,6 +114,22 @@
*/
class DB extends Facade
{
/**
* Indicate if destructive Artisan commands should be prohibited.
*
* Prohibits: db:wipe, migrate:fresh, migrate:refresh, and migrate:reset
*
* @param bool $prohibit
* @return void
*/
public static function prohibitDestructiveCommands(bool $prohibit = true)
{
FreshCommand::prohibit($prohibit);
RefreshCommand::prohibit($prohibit);
ResetCommand::prohibit($prohibit);
WipeCommand::prohibit($prohibit);
}

/**
* Get the registered name of the component.
*
Expand Down

0 comments on commit a39aca5

Please sign in to comment.