@@ -73,31 +73,8 @@ EOT
|
||||
}
|
||||
|
||||
if ($this->askConfirmation($input, $output, 'Do you want to drop and re-create the schema y/N ?')) {
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:schema:drop');
|
||||
$command->run(new ArrayInput(['--force' => true]), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop database schema: ' . $ex->getMessage());
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:query:sql');
|
||||
$command->run(new ArrayInput(['sql' => 'DROP TABLE IF EXISTS migration_versions']), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop migration_versions table: ' . $ex->getMessage());
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:query:sql');
|
||||
$command->run(new ArrayInput(['sql' => 'DROP TABLE IF EXISTS kimai2_sessions']), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop kimai2_sessions table: ' . $ex->getMessage());
|
||||
|
||||
return 4;
|
||||
if (($result = $this->dropSchema($io, $output)) !== 0) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -134,6 +111,38 @@ EOT
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function dropSchema(SymfonyStyle $io, OutputInterface $output): int
|
||||
{
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:schema:drop');
|
||||
$command->run(new ArrayInput(['--force' => true]), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop database schema: ' . $ex->getMessage());
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:query:sql');
|
||||
$command->run(new ArrayInput(['sql' => 'DROP TABLE IF EXISTS migration_versions']), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop migration_versions table: ' . $ex->getMessage());
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:query:sql');
|
||||
$command->run(new ArrayInput(['sql' => 'DROP TABLE IF EXISTS kimai2_sessions']), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop kimai2_sessions table: ' . $ex->getMessage());
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function askConfirmation(InputInterface $input, OutputInterface $output, string $question): bool
|
||||
{
|
||||
if (!$input->isInteractive()) {
|
||||
|
||||
Reference in New Issue
Block a user