feat: block destructive DB commands in production
Listen for CommandStarting event and throw RuntimeException for migrate:fresh, migrate:refresh, migrate:reset, db:wipe, db:seed when APP_ENV=production. Prevents accidental data loss even with --force. Also removes old non-functional closure-based override in routes/console.php.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
@@ -18,9 +17,3 @@ use Illuminate\Support\Facades\Artisan;
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
if ('production' === App::environment()) {
|
||||
Artisan::command('migrate:fresh', function () {
|
||||
$this->comment('You are not allowed to do this in production.');
|
||||
})->describe('Override default command in production.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user