diff --git a/src/Command/ResetCommand.php b/src/Command/ResetCommand.php index df535453..32056597 100644 --- a/src/Command/ResetCommand.php +++ b/src/Command/ResetCommand.php @@ -100,13 +100,33 @@ EOT } try { - $command = $this->getApplication()->find('doctrine:schema:create'); - $command->run(new ArrayInput([]), $output); + $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 create database schema: ' . $ex->getMessage()); + $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; + } + + try { + $command = $this->getApplication()->find('doctrine:migrations:migrate'); + $cmdInput = new ArrayInput([]); + $cmdInput->setInteractive(false); + $command->run($cmdInput, $output); + } catch (Exception $ex) { + $io->error('Failed to execute a migrations: ' . $ex->getMessage()); + + return 5; + } } try { @@ -117,18 +137,7 @@ EOT } catch (Exception $ex) { $io->error('Failed to import fixtures: ' . $ex->getMessage()); - return 4; - } - - try { - $command = $this->getApplication()->find('doctrine:migrations:version'); - $cmdInput = new ArrayInput(['--add' => true, '--all' => true]); - $cmdInput->setInteractive(false); - $command->run($cmdInput, $output); - } catch (Exception $ex) { - $io->error('Failed to set migration status: ' . $ex->getMessage()); - - return 5; + return 6; } if (!$input->getOption('no-cache')) { @@ -138,7 +147,7 @@ EOT } catch (Exception $ex) { $io->error('Failed to clear cache: ' . $ex->getMessage()); - return 6; + return 7; } }