Add sudo support for migrate commands when not running as root

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-23 10:12:49 +00:00
parent 192811e48a
commit b444f10c8e
4 changed files with 87 additions and 71 deletions

View File

@@ -10,6 +10,7 @@ use App\RSpade\Core\Database\MigrationPaths;
class Migrate_Commit_Command extends Command
{
use PrivilegedCommandTrait;
protected $signature = 'migrate:commit';
protected $description = 'Commit the migration changes and end the migration session';
@@ -88,7 +89,7 @@ class Migrate_Commit_Command extends Command
// Step 1: Remove backup directory
if (is_dir($this->backup_dir)) {
$this->info('[1] Removing backup snapshot...');
$this->run_command(['rm', '-rf', $this->backup_dir]);
$this->run_privileged_command(['rm', '-rf', $this->backup_dir]);
}
// Step 2: Remove migration flag
@@ -168,19 +169,4 @@ class Migrate_Commit_Command extends Command
return $unran;
}
/**
* Run a shell command
*/
protected function run_command(array $command): string
{
$process = new Process($command);
$process->setTimeout(60);
$process->run();
if (!$process->isSuccessful()) {
throw new \Exception($process->getErrorOutput());
}
return $process->getOutput();
}
}