diff --git a/src/Console/CreateUserCommand.php b/src/Console/CreateUserCommand.php index b715d04..f4c1328 100644 --- a/src/Console/CreateUserCommand.php +++ b/src/Console/CreateUserCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; #[AsCommand('app:user:create')] @@ -48,6 +49,14 @@ class CreateUserCommand extends Command $output->writeln(sprintf('User "%s" successfully created', $user)); + // ask to create a database for the user + $createDbQuestion = new ConfirmationQuestion('Create a database for this user?', false); + if ($question->ask($input, $output, $createDbQuestion)) { + $this->db->createDatabase($user); + $this->db->grantDatabaseAdminPermission($user, $user, $host); + $output->writeln(sprintf('Database "%s" successfully created and granted to "%s"', $user, $user)); + } + return Command::SUCCESS; } } \ No newline at end of file