private function applyMigration(Name $name, Direction $direction)
 {
     $migration = $this->service->createMigrationInstance($name, $this->output);
     if ($direction->isUp()) {
         $this->output->writeln('<info>Testing ' . $name . ' going up.</info>');
         $migration->up($this->service->getDatabase());
     } elseif ($direction->isDown()) {
         $this->output->writeln('<info>Testing ' . $name . ' going down.</info>');
         $migration->down($this->service->getDatabase());
     }
 }
 private function applyMigration(Name $name, Direction $direction)
 {
     $fullClassName = 'Mongrate\\Migrations\\' . $name;
     $migration = new $fullClassName();
     if ($direction->isUp()) {
         $this->output->writeln('<info>Testing ' . $name . ' going up.</info>');
         $migration->up($this->service->getDatabase());
     } elseif ($direction->isDown()) {
         $this->output->writeln('<info>Testing ' . $name . ' going down.</info>');
         $migration->down($this->service->getDatabase());
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = new Name($input->getArgument('name'));
     $isAlreadyApplied = $this->service->isMigrationApplied($name);
     if ($isAlreadyApplied === true) {
         $this->service->migrate($name, Direction::down(), $output);
     } else {
         $this->service->migrate($name, Direction::up(), $output);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = new Name($input->getArgument('name'));
     $force = $input->getOption('force');
     $isAlreadyApplied = $this->service->isMigrationApplied($name);
     if ($isAlreadyApplied === false && !$force) {
         throw new CannotApplyException('Cannot go down - the migration is not applied yet.');
     } else {
         $this->service->migrate($name, Direction::down(), $output);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->service->ensureMigrationsDirectoryExists();
     $migrationsNotApplied = $this->service->getMigrationsNotApplied();
     if (count($migrationsNotApplied) === 0) {
         $output->writeln('<info>There are no migrations to apply. They are all already applied.</info>');
         return;
     }
     foreach ($migrationsNotApplied as $migration) {
         $this->service->migrate($migration->getName(), Direction::up(), $output);
     }
     $output->writeln('<info>All migrations have been applied.</info>');
 }
 /**
  * Test to ensure down static method return an instance of Direction with 'down' direction.
  */
 public function testDown()
 {
     $direction = Direction::down();
     $this->assertTrue($direction instanceof Direction);
     $this->assertEquals(DirectionEnum::DOWN, $direction);
 }
 /**
  * Migrate up or down.
  *
  * @param Direction $direction
  */
 public function migrate(Name $name, Direction $direction, OutputInterface $output)
 {
     $migration = $this->createMigrationInstance($name, $output);
     $output->writeln('<info>Migrating ' . $direction . '...</info> <comment>' . $name . '</comment>');
     if ($direction->isUp()) {
         $migration->up($this->database);
         $this->setMigrationApplied($name, true);
     } else {
         $migration->down($this->database);
         $this->setMigrationApplied($name, false);
     }
     $output->writeln('<info>Migrated ' . $direction . '</info>');
 }
 /**
  * Migrate up or down.
  *
  * @param Direction $direction
  */
 public function migrate(Name $name, Direction $direction, OutputInterface $output)
 {
     $this->loadMigrationClass($name);
     $fullClassName = $this->generateFullClassName($name);
     $migration = new $fullClassName();
     $output->writeln('<info>Migrating ' . $direction . '...</info> <comment>' . $name . '</comment>');
     if ($direction->isUp()) {
         $migration->up($this->database);
         $this->setMigrationApplied($name, true);
     } else {
         $migration->down($this->database);
         $this->setMigrationApplied($name, false);
     }
     $output->writeln('<info>Migrated ' . $direction . '</info>');
 }