Execute migrations in kimai:reset-dev command (#1982)

This commit is contained in:
Kacper Rogula
2020-10-03 14:56:51 +02:00
committed by GitHub
parent 825e492891
commit bb97611349

View File

@@ -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;
}
}