diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index 964508fa..6027a53b 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -224,17 +224,28 @@ class InstallCommand extends Command protected function importMigrations(SymfonyStyle $io, OutputInterface $output) { - if ($this->connection->getSchemaManager()->tablesExist(['migration_versions'])) { - $amount = $this->connection->executeQuery('SELECT count(*) as counter FROM migration_versions')->fetchColumn(0); - if ($amount > 0) { - $io->note(sprintf('Found %s migrations in your database, skipping import', $amount)); + if (!$this->connection->getSchemaManager()->tablesExist(['migration_versions'])) { + $command = $this->getApplication()->find('doctrine:migrations:version'); + $cmdInput = new ArrayInput(['--add' => true, '--all' => true]); + $cmdInput->setInteractive(false); + $command->run($cmdInput, $output); - return; - } + return; } - $command = $this->getApplication()->find('doctrine:migrations:version'); - $cmdInput = new ArrayInput(['--add' => true, '--all' => true]); + // this case should not happen, but you know ... everything is possible + $amount = $this->connection->executeQuery('SELECT count(*) as counter FROM migration_versions')->fetchColumn(0); + if ($amount === 0) { + $command = $this->getApplication()->find('doctrine:migrations:version'); + $cmdInput = new ArrayInput(['--add' => true, '--all' => true]); + $cmdInput->setInteractive(false); + $command->run($cmdInput, $output); + + return; + } + + $command = $this->getApplication()->find('doctrine:migrations:migrate'); + $cmdInput = new ArrayInput(['--allow-no-migration' => true]); $cmdInput->setInteractive(false); $command->run($cmdInput, $output); diff --git a/src/Repository/ActivityRepository.php b/src/Repository/ActivityRepository.php index e5264959..b8bfd362 100644 --- a/src/Repository/ActivityRepository.php +++ b/src/Repository/ActivityRepository.php @@ -81,6 +81,18 @@ class ActivityRepository extends EntityRepository return $stats; } + /** + * @deprecated since 1.1 + */ + public function builderForEntityType($activity, $project) + { + $query = new ActivityFormTypeQuery(); + $query->setActivity($activity); + $query->setProject($project); + + return $this->getQueryBuilderForFormType($query); + } + /** * Returns a query builder that is used for ActivityType and your own 'query_builder' option. * diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index 658d62c3..1c38d957 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -107,6 +107,17 @@ class CustomerRepository extends EntityRepository return $stats; } + /** + * @deprecated since 1.1 + */ + public function builderForEntityType($customer) + { + $query = new CustomerFormTypeQuery(); + $query->setCustomer($customer); + + return $this->getQueryBuilderForFormType($query); + } + /** * Returns a query builder that is used for CustomerType and your own 'query_builder' option. * diff --git a/src/Repository/ProjectRepository.php b/src/Repository/ProjectRepository.php index 9a91d4f6..a321bb38 100644 --- a/src/Repository/ProjectRepository.php +++ b/src/Repository/ProjectRepository.php @@ -91,6 +91,18 @@ class ProjectRepository extends EntityRepository return $stats; } + /** + * @deprecated since 1.1 + */ + public function builderForEntityType($project, $customer) + { + $query = new ProjectFormTypeQuery(); + $query->setProject($project); + $query->setCustomer($customer); + + return $this->getQueryBuilderForFormType($query); + } + /** * Returns a query builder that is used for ProjectType and your own 'query_builder' option. * diff --git a/tests/Command/InstallCommandTest.php b/tests/Command/InstallCommandTest.php index 944a6e45..6e9b5cc7 100644 --- a/tests/Command/InstallCommandTest.php +++ b/tests/Command/InstallCommandTest.php @@ -85,8 +85,9 @@ class InstallCommandTest extends KernelTestCase self::assertContains('[NOTE] It seems as if you already have the required tables in your database,', $result); self::assertContains('skipping schema creation', $result); - self::assertContains('[NOTE] Found ', $result); - self::assertContains(' migrations in your database, skipping import', $result); + // make sure migrations run always + self::assertContains('Application Migrations', $result); + self::assertContains('No migrations to execute.', $result); self::assertContains( sprintf('[OK] Congratulations! Kimai 2 (%s %s) was successful installed!', Constants::VERSION, Constants::STATUS), diff --git a/var/data/kimai_test.sqlite b/var/data/kimai_test.sqlite index e848b896..52d4e23d 100644 Binary files a/var/data/kimai_test.sqlite and b/var/data/kimai_test.sqlite differ