Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option for Automatic Migration When Specifying a Database #327

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected function configure()
->addOption('verification', null, InputOption::VALUE_NONE, 'Indicates whether Jetstream should be scaffolded with email verification support')
->addOption('pest', null, InputOption::VALUE_NONE, 'Installs the Pest testing framework')
->addOption('phpunit', null, InputOption::VALUE_NONE, 'Installs the PHPUnit testing framework')
->addOption('migration', null, InputOption::VALUE_NONE, 'Automatically run the default database migrations after installation')
->addOption('prompt-breeze', null, InputOption::VALUE_NONE, 'Issues a prompt to determine if Breeze should be installed (Deprecated)')
->addOption('prompt-jetstream', null, InputOption::VALUE_NONE, 'Issues a prompt to determine if Jetstream should be installed (Deprecated)')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces install even if the directory already exists');
Expand Down Expand Up @@ -463,11 +464,15 @@ protected function promptForDatabaseOptions(string $directory, InputInterface $i
default: $defaultDatabase
));

if ($input->getOption('database') !== $defaultDatabase) {
if (! $input->getOption('migration') && $input->getOption('database') !== $defaultDatabase) {
$migrate = confirm(label: 'Default database updated. Would you like to run the default database migrations?', default: true);
}
}

if ($input->getOption('migration')) {
$migrate = true;
}

return [$input->getOption('database') ?? $defaultDatabase, $migrate ?? false];
}

Expand Down