First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
class MigrateFreshCommand extends Command
{
protected static $defaultName = 'migrate:fresh';
protected static $defaultDescription = 'Drop all tables and re-run all migrations';
protected function configure(): void
{
$this
->addOption('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed command should be re-run');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Iniciando limpeza do banco de dados (fresh)...</info>');
// 1. Wipe database
$wipeCommand = $this->getApplication()->find('db:wipe');
$wipeInput = new ArrayInput(['--force' => true]);
$wipeCommand->run($wipeInput, $output);
// 2. Run migrations
$migrateCommand = $this->getApplication()->find('migrate');
$migrateInput = new ArrayInput([]);
$migrateCommand->run($migrateInput, $output);
// 3. Optional seed
if ($input->getOption('seed')) {
$seedCommand = $this->getApplication()->find('db:seed');
$seedInput = new ArrayInput([]);
$seedCommand->run($seedInput, $output);
}
$output->writeln('<info>Operação migrate:fresh concluída com sucesso!</info>');
return Command::SUCCESS;
}
}