Skip to content

Commit 68d3cc6

Browse files
committed
Update MigrateCleanCommand.php
Add help, add -f option to bypass confirmation prompt
1 parent e24d370 commit 68d3cc6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

app/sprinkles/core/src/Bakery/MigrateCleanCommand.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ protected function configure()
3131
{
3232
$this->setName('migrate:clean')
3333
->setDescription('Remove stale migrations from the database.')
34-
->addOption('database', 'd', InputOption::VALUE_REQUIRED, 'The database connection to use.');
34+
->setHelp('Removes stale migrations, which are simply migration class files that have been removed from the Filesystem. E.g. if you run a migration and then delete the migration class file prior to running `down()` for that migration it becomes stale. If a migration is a dependency of another migration you probably want to try to restore the files instead of running this command to avoid further issues.')
35+
->addOption('database', 'd', InputOption::VALUE_REQUIRED, 'The database connection to use.')
36+
->addOption('force', 'f', InputOption::VALUE_NONE, 'Do not prompt for confirmation.');
3537
}
3638

3739
/**
@@ -60,11 +62,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
6062
$stale = $this->getStaleRecords($ran, $available);
6163

6264
if ($stale->count() > 0) {
63-
$this->io->section('Stale migrations');
64-
$this->io->listing($stale->toArray());
65+
if (!$input->getOption('force')) {
66+
$this->io->section('Stale migrations');
67+
$this->io->listing($stale->toArray());
6568

66-
if (!$this->io->confirm('Continue and remove stale migrations?', false)) {
67-
exit;
69+
if (!$this->io->confirm('Continue and remove stale migrations?', false)) {
70+
exit;
71+
}
6872
}
6973
$this->io->section('Cleaned migrations');
7074
$this->cleanStaleRecords($stale, $migrator);

0 commit comments

Comments
 (0)