Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$this->setupDatabase($input, $output)) {
         return;
     }
     $name = $input->getArgument('connection');
     $conn = $this->manager->getConnection($name);
     $output->writeln('');
     $output->writeln(sprintf('Migrate UP: <info>%s</info>', $name));
     $migration = new MigrationManager($conn);
     $config = $this->createMigrationConfig();
     $count = 0;
     foreach ($config->getMigrations() as $version => $file) {
         if ($migration->executeMigrationUp($migration->instantiateMigration($file))) {
             $output->writeln('');
             $output->writeln(sprintf('<info>%s</info>', $version));
             $output->writeln('  ' . $file);
             $count++;
         }
     }
     $output->writeln('');
     $output->writeln(sprintf('<info>%s</info> DB migrations applied', $count));
 }
Example #2
0
 public function migrateConnectionUp($connectionName)
 {
     $conn = $this->connectionManager->getConnection($connectionName);
     $migrator = new MigrationManager($conn);
     $config = new MigrationConfig();
     foreach ($this->testKernel->getKomponents() as $komponent) {
         if ($komponent instanceof MigrationProviderInterface) {
             $komponent->loadMigrations($config);
         }
     }
     foreach ($config->getMigrations() as $version => $file) {
         if ($migrator->executeMigrationUp($migrator->instantiateMigration($file))) {
             $this->logger->info('Executed UP migration {version} using connection {conn}', ['version' => $version, 'conn' => (string) $connectionName]);
         }
     }
 }