public function fire(\Doctrine\ORM\EntityManagerInterface $d2em)
 {
     $validator = new SchemaValidator($d2em);
     $exit = 0;
     if ($this->option('skip-mapping')) {
         $this->comment('[Mapping]  Skipped mapping check.');
     } elseif ($errors = $validator->validateMapping()) {
         foreach ($errors as $className => $errorMessages) {
             $this->error("[Mapping]  FAIL - The entity-class '" . $className . "' mapping is invalid:");
             foreach ($errorMessages as $errorMessage) {
                 $this->line('* ' . $errorMessage);
             }
             $this->line();
         }
         $exit += 1;
     } else {
         $this->info("[Mapping]  OK - The mapping files are correct.");
     }
     if ($this->option('skip-sync')) {
         $this->comment("[Database] SKIPPED - The database was not checked for synchronicity.");
     } elseif (!$validator->schemaInSyncWithMetadata()) {
         $this->error("[Database] FAIL - The database schema is not in sync with the current mapping file.");
         $exit += 2;
     } else {
         $this->info("[Database] OK - The database schema is in sync with the mapping files.");
     }
 }
 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $validator = new SchemaValidator($em);
         $this->comment('');
         $this->message('Validating for <info>' . $name . '</info> entity manager...');
         if ($this->option('skip-mapping')) {
             $this->comment('Mapping]  Skipped mapping check.');
         } elseif ($errors = $validator->validateMapping()) {
             foreach ($errors as $className => $errorMessages) {
                 $this->error("[Mapping]  FAIL - The entity-class '" . $className . "' mapping is invalid:");
                 $this->comment('');
                 foreach ($errorMessages as $errorMessage) {
                     $this->message('* ' . $errorMessage, 'red');
                 }
             }
         } else {
             $this->info('[Mapping]  OK - The mapping files are correct.');
         }
         if ($this->option('skip-sync')) {
             $this->comment('Database] SKIPPED - The database was not checked for synchronicity.');
         } elseif (!$validator->schemaInSyncWithMetadata()) {
             $this->error('[Database] FAIL - The database schema is not in sync with the current mapping file.');
         } else {
             $this->info('[Database] OK - The database schema is in sync with the mapping files.');
         }
     }
 }
Example #3
0
 /**
  * @group DDC-1439
  */
 public function testInvalidToOneJoinColumnSchema()
 {
     $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\\InvalidEntity1');
     $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\\InvalidEntity2');
     $ce = $this->validator->validateClass($class2);
     $this->assertEquals(array("The referenced column name 'id' does not have a corresponding field with this column name on the class 'Doctrine\\Tests\\ORM\\Tools\\InvalidEntity1'.", "The join columns of the association 'assoc' have to match to ALL identifier columns of the source entity 'Doctrine\\Tests\\ORM\\Tools\\InvalidEntity2', however 'key3, key4' are missing."), $ce);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $validator = new SchemaValidator($em);
     $exit = 0;
     if ($input->getOption('skip-mapping')) {
         $output->writeln('<comment>[Mapping]  Skipped mapping check.</comment>');
     } elseif ($errors = $validator->validateMapping()) {
         foreach ($errors as $className => $errorMessages) {
             $output->writeln("<error>[Mapping]  FAIL - The entity-class '" . $className . "' mapping is invalid:</error>");
             foreach ($errorMessages as $errorMessage) {
                 $output->writeln('* ' . $errorMessage);
             }
             $output->writeln('');
         }
         $exit += 1;
     } else {
         $output->writeln('<info>[Mapping]  OK - The mapping files are correct.</info>');
     }
     if ($input->getOption('skip-sync')) {
         $output->writeln('<comment>[Database] SKIPPED - The database was not checked for synchronicity.</comment>');
     } elseif (!$validator->schemaInSyncWithMetadata()) {
         $output->writeln('<error>[Database] FAIL - The database schema is not in sync with the current mapping file.</error>');
         $exit += 2;
     } else {
         $output->writeln('<info>[Database] OK - The database schema is in sync with the mapping files.</info>');
     }
     return $exit;
 }
 public function testSchemaIsValid()
 {
     $this->createClient();
     $validator = new SchemaValidator(self::$kernel->getContainer()->get('doctrine.orm.entity_manager'));
     $errors = $validator->validateMapping();
     $this->assertEmpty($errors, "Validation errors found: \n\n" . var_export($errors, true));
 }
 /**
  * Validates the metadata mapping for Doctrine, using the SchemaValidator
  * of Doctrine.
  *
  * @return array
  */
 public function validateMapping()
 {
     try {
         $validator = new SchemaValidator($this->entityManager);
         return $validator->validateMapping();
     } catch (\Exception $exception) {
         return array(array($exception->getMessage()));
     }
 }
Example #7
0
 public function testMapping()
 {
     /** @var ManagerRegistry $registry */
     $registry = $this->getContainer()->get('doctrine');
     /** @var EntityManager $em */
     foreach ($registry->getManagers() as $em) {
         $validator = new SchemaValidator($em);
         $validateMapping = $validator->validateMapping();
         $this->assertEmpty($validateMapping, implode("\n", $validateMapping));
     }
 }
Example #8
0
 /**
  * Doctrine schema validation
  */
 public function testValidateSchema()
 {
     $validator = new SchemaValidator($this->em);
     $errors = $validator->validateMapping();
     if (count($errors) > 0) {
         $message = PHP_EOL;
         foreach ($errors as $class => $classErrors) {
             $message .= "- " . $class . ":" . PHP_EOL . implode(PHP_EOL, $classErrors) . PHP_EOL . PHP_EOL;
         }
         $this->fail($message);
     }
 }
 /**
  * @dataProvider dataValidateModelSets
  */
 public function testValidateModelSets($modelSet)
 {
     $validator = new SchemaValidator($this->_em);
     $classes = array();
     foreach (self::$_modelSets[$modelSet] as $className) {
         $classes[] = $this->_em->getClassMetadata($className);
     }
     foreach ($classes as $class) {
         $ce = $validator->validateClass($class);
         $this->assertEquals(0, count($ce), "Invalid Modelset: " . $modelSet . " class " . $class->name . ": " . implode("\n", $ce));
     }
 }
 /**
  * @throws InvalidMappingException
  */
 public function assertSchemaIsValid()
 {
     if ($this->needValidate()) {
         foreach ($this->doctrine->getManagers() as $managerName => $manager) {
             $validator = new SchemaValidator($manager);
             foreach ($validator->validateMapping() as $entity => $errors) {
                 $this->assertAuthorizedMappingErrors($managerName, $entity, $errors);
             }
         }
         $this->saveLastValidateTimestamp();
     }
 }
 /**
  * @see ExtensionInterface
  */
 public function register($provider, $configuration)
 {
     if ($provider->isInitialized('entity.manager')) {
         // Skip the validation if the app didn't connect to the database
         return;
     }
     $validator = new SchemaValidator($provider->lookup('entity.manager'));
     $errors = $validator->validateMapping();
     if (!empty($errors)) {
         throw new ConfigurationException(sprintf('The database schema is not valid: %s', print_r($errors, true)));
     }
 }
Example #12
0
 public static function init()
 {
     $zf2ModulePaths = [dirname(dirname(__DIR__))];
     if ($path = static::findParentPath('vendor')) {
         $zf2ModulePaths[] = $path;
     }
     if ($path = static::findParentPath('module')) {
         $zf2ModulePaths[] = $path;
     }
     if (($path = static::findParentPath('src')) !== $zf2ModulePaths[0]) {
         $zf2ModulePaths[] = $path;
     }
     static::initAutoloader();
     $config = (include __DIR__ . '/../config/application.config.php');
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
     if (defined("TEST_SUITE") && constant("TEST_SUITE") == 'full') {
         $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
         //Validate the schema;
         $validator = new SchemaValidator($entityManager);
         $errors = $validator->validateMapping();
         if (count($errors) > 0) {
             foreach ($errors as $entity => $errors) {
                 echo "Error in Entity: '" . $entity . "':\n";
                 echo implode("\n", $errors);
                 echo "\n";
             }
             die;
         }
         //Create the schema
         $tool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
         $mdFactory = $entityManager->getMetadataFactory();
         $mdFactory->getAllMetadata();
         $tool->dropDatabase();
         $tool->createSchema($mdFactory->getAllMetadata());
         $loader = new Loader();
         $loader->addFixture(new \AdminTest\Fixture\LoadAccessData());
         $loader->addFixture(new LoadCountryData());
         $loader->addFixture(new LoadDomainData());
         $loader->addFixture(new LoadProgramData());
         $loader->addFixture(new LoadContactData());
         $loader->addFixture(new LoadContentTypeData());
         $purger = new ORMPurger();
         $executor = new ORMExecutor($entityManager, $purger);
         $executor->execute($loader->getFixtures());
     }
 }
 /**
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     static::$kernel = static::createKernel(array());
     static::$kernel->boot();
     $metadata = static::getMetadata();
     $tool = new SchemaTool(static::$em);
     $tool->dropDatabase();
     $tool->createSchema($metadata);
     $validator = new SchemaValidator(static::$em);
     $errors = $validator->validateMapping();
     static::assertCount(0, $errors, implode("\n\n", array_map(function ($l) {
         return implode("\n\n", $l);
     }, $errors)));
 }
 /**
  * @dataProvider dataValidateModelSets
  */
 public function testValidateModelSets($modelSet)
 {
     $validator = new SchemaValidator($this->_em);
     $classes = array();
     foreach (self::$_modelSets[$modelSet] as $className) {
         $classes[] = $this->_em->getClassMetadata($className);
     }
     foreach ($classes as $class) {
         $ce = $validator->validateClass($class);
         foreach ($ce as $key => $error) {
             if (strpos($error, "must be private or protected. Public fields may break lazy-loading.") !== false) {
                 unset($ce[$key]);
             }
         }
         $this->assertEquals(0, count($ce), "Invalid Modelset: " . $modelSet . " class " . $class->name . ": " . implode("\n", $ce));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     parent::collect($request, $response, $exception);
     $errors = array();
     $entities = array();
     foreach ($this->registry->getManagers() as $name => $em) {
         $entities[$name] = array();
         /** @var $factory \Doctrine\ORM\Mapping\ClassMetadataFactory */
         $factory = $em->getMetadataFactory();
         $validator = new SchemaValidator($em);
         /** @var $class \Doctrine\ORM\Mapping\ClassMetadataInfo */
         foreach ($factory->getLoadedMetadata() as $class) {
             $entities[$name][] = $class->getName();
             $classErrors = $validator->validateClass($class);
             if (!empty($classErrors)) {
                 $errors[$name][$class->getName()] = $classErrors;
             }
         }
     }
     $this->data['entities'] = $entities;
     $this->data['errors'] = $errors;
 }
Example #16
0
 /**
  *  Создает схему БД
  *
  * @throws \Doctrine\ORM\Tools\ToolsException
  * @throws \RuntimeException
  */
 public function createSchema()
 {
     $em = $this->getEntityManager();
     //        $em->getConnection()->executeQuery('DROP DATABASE `workflow-doctrine`');
     //        $em->getConnection()->executeQuery('CREATE DATABASE `workflow-doctrine`');
     //        $em->getConnection()->close();
     //        $em->getConnection()->connect();
     $validator = new SchemaValidator($em);
     $errors = $validator->validateMapping();
     $errMsg = [];
     foreach ($errors as $className => $errorMessages) {
         foreach ($errorMessages as $errorMessage) {
             $errMsg[] = $errorMessage;
         }
     }
     if (count($errMsg) > 0) {
         throw new \RuntimeException(implode("\n", $errMsg));
     }
     $tool = new SchemaTool($em);
     $metadata = $em->getMetadataFactory()->getAllMetadata();
     $tool->dropDatabase();
     $tool->createSchema($metadata);
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $queries = array();
     foreach ($this->loggers as $name => $logger) {
         $queries[$name] = $this->sanitizeQueries($name, $logger->queries);
     }
     $this->data = array('queries' => $queries, 'connections' => $this->connections, 'managers' => $this->managers);
     $errors = array();
     $entities = array();
     $entities['default'] = array();
     /** @var $factory \Doctrine\ORM\Mapping\ClassMetadataFactory */
     $factory = $this->container->get('em')->getMetadataFactory();
     $validator = new SchemaValidator($this->container->get('em'));
     /** @var $class \Doctrine\ORM\Mapping\ClassMetadataInfo */
     foreach ($factory->getLoadedMetadata() as $class) {
         $entities['default'][] = $class->getName();
         $classErrors = $validator->validateClass($class);
         if (!empty($classErrors)) {
             $errors['default'][$class->getName()] = $classErrors;
         }
     }
     $this->data['entities'] = $entities;
     $this->data['errors'] = $errors;
 }
Example #18
0
 /**
  * checks if the schema in configured datastore is in sync with doctrine entities
  * @return boolean	true, if the schema is correct
  */
 public function checkSchema()
 {
     //get instances
     $ormController = OrmController::create();
     $entityManager = $ormController->getEntityManager();
     $schemaValidator = new SchemaValidator($entityManager);
     //check schema
     return $schemaValidator->schemaInSyncWithMetadata();
 }
Example #19
0
 public function validateTables()
 {
     //Make sure Doctrine is happy with all that
     $validator = new SchemaValidator($this->db->getDoctrine());
     $errors = $validator->validateMapping();
     if (count($errors) > 0) {
         foreach ($errors as $error) {
             if (is_array($error)) {
                 echo implode("<br />", $error);
             } else {
                 echo $error;
             }
         }
     }
 }
 /**
  * @group DDC-3322
  */
 public function testInvalidOrderByAssociationInverseSide()
 {
     $class = $this->em->getClassMetadata(__NAMESPACE__ . '\\DDC3322Three');
     $ce = $this->validator->validateClass($class);
     $this->assertEquals(array("The association Doctrine\\Tests\\ORM\\Tools\\DDC3322Three#invalidAssoc is ordered by a field oneToOneInverse " . "on Doctrine\\Tests\\ORM\\Tools\\DDC3322ValidEntity1 that is the inverse side of an association."), $ce);
 }
 /**
  * @Then I the tool should apply the DDL to the database
  */
 public function checkAppliedDDL()
 {
     $tool = new SchemaValidator($this->getEntityManager());
     Assertion::true($tool->schemaInSyncWithMetadata());
     Assertion::regex($this->tester->getDisplay(), '/Validated 1 manager, 1 needed schema appliance, 0 was in sync\\./');
 }
Example #22
0
 /**
  * Método que valida se o mapeamento de uma classe específica
  * está coerente com a sua tabela correspondente
  * @param string $nome FQCN da classe
  * @return boolean
  */
 public function validarClasse($nome)
 {
     $sv = new SchemaValidator($this->em);
     return $sv->validateClass($this->em->getClassMetadata($nome));
 }
 /**
  * @group DDC-1649
  */
 public function testInvalidTripleAssociationAsKeyMapping()
 {
     $classThree = $this->em->getClassMetadata(__NAMESPACE__ . '\\DDC1649Three');
     $ce = $this->validator->validateClass($classThree);
     $this->assertEquals(array("Cannot map association 'Doctrine\\Tests\\ORM\\Tools\\DDC1649Three#two as identifier, because the target entity 'Doctrine\\Tests\\ORM\\Tools\\DDC1649Two' also maps an association as identifier.", "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\\Tests\\ORM\\Tools\\DDC1649Two'."), $ce);
 }
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     parent::collect($request, $response, $exception);
     $errors = array();
     $entities = array();
     $caches = array('enabled' => false, 'log_enabled' => false, 'counts' => array('puts' => 0, 'hits' => 0, 'misses' => 0), 'regions' => array('puts' => array(), 'hits' => array(), 'misses' => array()));
     foreach ($this->registry->getManagers() as $name => $em) {
         $entities[$name] = array();
         /** @var $factory \Doctrine\ORM\Mapping\ClassMetadataFactory */
         $factory = $em->getMetadataFactory();
         $validator = new SchemaValidator($em);
         /** @var $class \Doctrine\ORM\Mapping\ClassMetadataInfo */
         foreach ($factory->getLoadedMetadata() as $class) {
             $entities[$name][] = $class->getName();
             $classErrors = $validator->validateClass($class);
             if (!empty($classErrors)) {
                 $errors[$name][$class->getName()] = $classErrors;
             }
         }
         if (version_compare(\Doctrine\ORM\Version::VERSION, '2.5.0-DEV') < 0) {
             continue;
         }
         /** @var $emConfig \Doctrine\ORM\Configuration */
         $emConfig = $em->getConfiguration();
         $slcEnabled = $emConfig->isSecondLevelCacheEnabled();
         if (!$slcEnabled) {
             continue;
         }
         $caches['enabled'] = true;
         /** @var $cacheConfiguration \Doctrine\ORM\Cache\CacheConfiguration */
         /** @var $clacheLoggerChain \Doctrine\ORM\Cache\Logging\CacheLoggerChain */
         $cacheConfiguration = $emConfig->getSecondLevelCacheConfiguration();
         $cacheLoggerChain = $cacheConfiguration->getCacheLogger();
         if (!$cacheLoggerChain || !$cacheLoggerChain->getLogger('statistics')) {
             continue;
         }
         /** @var $cacheLoggerStats \Doctrine\ORM\Cache\Logging\StatisticsCacheLogger */
         $cacheLoggerStats = $cacheLoggerChain->getLogger('statistics');
         $caches['log_enabled'] = true;
         $caches['counts']['puts'] += $cacheLoggerStats->getPutCount();
         $caches['counts']['hits'] += $cacheLoggerStats->getHitCount();
         $caches['counts']['misses'] += $cacheLoggerStats->getMissCount();
         foreach ($cacheLoggerStats->getRegionsPut() as $key => $value) {
             if (!isset($caches['regions']['puts'][$key])) {
                 $caches['regions']['puts'][$key] = 0;
             }
             $caches['regions']['puts'][$key] += $value;
         }
         foreach ($cacheLoggerStats->getRegionsHit() as $key => $value) {
             if (!isset($caches['regions']['hits'][$key])) {
                 $caches['regions']['hits'][$key] = 0;
             }
             $caches['regions']['hits'][$key] += $value;
         }
         foreach ($cacheLoggerStats->getRegionsMiss() as $key => $value) {
             if (!isset($caches['regions']['misses'][$key])) {
                 $caches['regions']['misses'][$key] = 0;
             }
             $caches['regions']['misses'][$key] += $value;
         }
     }
     $this->data['entities'] = $entities;
     $this->data['errors'] = $errors;
     $this->data['caches'] = $caches;
 }
Example #25
0
    /**
     * @test
     */
    public function shouldAllSchemasBeValid()
    {
        $schemaValidator = new SchemaValidator($this->em);

        $this->assertEmpty($schemaValidator->validateMapping());
    }
 public function testRoutingModelSet()
 {
     $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array(__DIR__ . "/../../Models/Routing"));
     $this->validator->validateMapping();
 }
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException If the strategy is invalid.
  * @throws \InvalidArgumentException If the fixtures config is invalid.
  */
 protected function execute(InputInterface $input, OutputInterface $output) : int
 {
     $environment = $this->getContainer()->getParameter('kernel.environment');
     $application = $this->getApplication();
     $strategy = $input->getOption('strategy');
     $productionFixtures = $input->getOption('production-fixtures');
     $validatedDatabases = [];
     if (!in_array($strategy, [self::STRATEGY_SCHEMA_UPDATE, self::STRATEGY_MIGRATIONS], true)) {
         throw new \InvalidArgumentException(sprintf('The strategy must be either "%s" or "%s"!', self::STRATEGY_MIGRATIONS, self::STRATEGY_SCHEMA_UPDATE));
     }
     /** @var \Doctrine\Common\Persistence\ManagerRegistry $registry */
     $registry = $this->getContainer()->get('doctrine');
     // initialize counters
     $count = $applied = $fixtureApplied = $inSync = 0;
     foreach ($input->getArgument('managers') as $manager) {
         $output->writeln(sprintf('<comment>Applying schema for manager "%s"...</comment>', $manager));
         ++$count;
         /** @var \Doctrine\ORM\EntityManagerInterface $em */
         $em = $registry->getManager($manager);
         $tool = new SchemaTool($em);
         $validator = new SchemaValidator($em);
         // the SchemaValidator is able to test the internal entity metadata
         // against the database DDL. If multiple entity managers have the same connection,
         // every validator instance will ONLY check the metadata of its associated
         // entity manager.
         if (!$validator->schemaInSyncWithMetadata()) {
             // execute strategy by schema
             if (self::STRATEGY_SCHEMA_UPDATE === $strategy) {
                 // At this place we UPDATE the whole schema instead of applying everything:
                 // This is due to the issue that a schema can be partially in sync, but this tool would detect
                 // the schema of the corresponding entity manager as outdated and would run the appliance again.
                 // If the appliance would force to recreate everything, tons of `Table or view exists` errors
                 // would arise.
                 $tool->updateSchema($em->getMetadataFactory()->getAllMetadata());
             } else {
                 // Especially on prod environments it's safer to rely on the migrations framework.
                 $command = $application->find('doctrine:migrations:migrate');
                 $migrationInput = new ArrayInput(['--env' => $environment]);
                 // migrations should be used in order to ensure on production environments
                 // with already existing data that the data will be preserved
                 // using custom migration classes for DDL changes.
                 $migrationInput->setInteractive(false);
                 $command->run($migrationInput, new NullOutput());
             }
             ++$applied;
         } else {
             ++$inSync;
         }
         $shouldApplyFixtures = $input->getOption('apply-fixtures');
         if ($productionFixtures && !$shouldApplyFixtures) {
             throw new \InvalidArgumentException('The `--production-fixtures` option must not be set if the `--apply-fixtures` option is not present!');
         }
         // fixture appliance:
         // the database installation process may include a fixture appliance, if the `--apply-fixtures` flag
         // is set.
         // If configured, only production fixtures will be applied.
         if ($shouldApplyFixtures) {
             $connection = $em->getConnection();
             $database = $connection->getDatabase();
             $shouldAppend = $apply = $input->getOption('append');
             // ensure that the validation is not executed multiple times.
             // if two entity managers have the same connection, but different metadata
             // and the database is not empty, this information should be cached in order
             // to avoid calculations when possible.
             if (!isset($validatedDatabases[$database]) && !$shouldAppend) {
                 // build an SQL query which ensures that the database is empty
                 $migrationsTable = $this->getContainer()->getParameter('doctrine_migrations.table_name');
                 $template = '(SELECT COUNT(:col) FROM :table)';
                 $tables = $connection->getSchemaManager()->createSchema()->getTables();
                 $tableCountSQL = array_map(function (Table $table) use($template, $migrationsTable) : string {
                     $name = $table->getName();
                     // migration table needs to be skipped.
                     if ($migrationsTable === $name) {
                         return '(0)';
                     }
                     $primaryKeys = $table->getPrimaryKeyColumns();
                     $column = count($primaryKeys) === 0 ? '*' : $primaryKeys[0];
                     return strtr($template, [':col' => $column, ':table' => $name]);
                 }, $tables);
                 $statement = $connection->prepare(sprintf('SELECT (%s) AS rows', implode('+', $tableCountSQL)));
                 $statement->execute();
                 // if the result is higher than zero, the appliance should be skipped
                 // since it the table is not empty.
                 $validatedDatabases[$database] = $apply = (int) $statement->fetch()['rows'] === 0;
             } elseif (isset($validatedDatabases[$database])) {
                 $apply = $validatedDatabases[$database];
             }
             if ($input->isInteractive() && !$apply) {
                 $question = new ConfirmationQuestion('<question>Careful, database is not empty. Should the fixtures be applied anyway (y/n)?</question>', false);
                 /** @var \Symfony\Component\Console\Helper\QuestionHelper $questionHelper */
                 $questionHelper = $this->getHelper('question');
                 if (!$questionHelper->ask($input, $output, $question)) {
                     $output->writeln(sprintf('<comment>Skipping fixture appliance for manager "%s"!</comment>', $manager));
                     continue;
                 }
                 $apply = true;
             }
             // checks whether fixtures should be applied (`--apply-fixtures`) and whether the database
             // is empty. Unless the whole process will be interrupted to avoid clearing accidentally the database.
             if ($apply) {
                 $target = $productionFixtures ? 'sententiaregum:fixtures:production' : 'doctrine:fixtures:load';
                 $output->writeln(sprintf('<comment>Applying fixtures for manager "%s" with environment "%s"!</comment>', $manager, $environment));
                 $args = ['--env' => $environment];
                 if ($shouldAppend) {
                     // the `LoadCustomFixturesCommand` doesn't support appending due to the fact that
                     // the production fixtures are only some very basic items that don't need to be appended,
                     // but should be executed at first and changed by migrations (model partially depends).
                     if ($productionFixtures) {
                         $output->writeln(sprintf('<error>Skipping `--append` flag for manager "%s" because `--production-fixtures` option is set</error>', $manager));
                         continue;
                     } else {
                         $args['--append'] = true;
                     }
                 }
                 $command = $application->find($target);
                 $fixtureInput = new ArrayInput($args);
                 $fixtureInput->setInteractive(false);
                 $command->run($fixtureInput, new NullOutput());
                 ++$fixtureApplied;
                 continue;
             }
         }
         // the skip notice should be displayed all the time if the fixture flag is set,
         // but the notice will be skipped.
         $message = sprintf('Skipping fixture appliance for manager "%s" because the database is not empty %s', $manager, $input->isInteractive() ? ' and the confirmation has been answered with no' : ' and the interaction mode is disabled, so no confirmation whether to force appliance can be used');
         $output->writeln(sprintf('<comment>%s!</comment>', $message));
     }
     // add an empty line before result stats
     $output->writeln('');
     $output->writeln(sprintf('<info>Validated %d %s, %d needed schema appliance, %d %s in sync. %d %s %s fixtures were applied.</info>', $count, $this->pluralize($count, 'managers', 'manager'), $applied, $inSync, $this->pluralize($count, 'were', 'was'), $fixtureApplied, $this->pluralize($fixtureApplied, 'times', 'time'), $productionFixtures ? 'production' : 'all'));
     return 0;
 }