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);
     }
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = new Name($input->getArgument('name'));
     $force = $input->getOption('force');
     $isAlreadyApplied = $this->service->isMigrationApplied($name);
     if ($isAlreadyApplied === true && !$force) {
         throw new CannotApplyException('Cannot go up - the migration is already applied.');
     } else {
         $this->service->migrate($name, Direction::up(), $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>');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $name = new Name($input->getArgument('name'));
     $direction = $input->getArgument('direction') ? new Direction($input->getArgument('direction')) : null;
     $classFile = $this->service->getMigrationClassFileFromName($name);
     if (file_exists($classFile)) {
         require_once $classFile;
     } else {
         throw new MigrationDoesntExist($name, $classFile);
     }
     $this->service->switchToDatabase('mongrate_test_' . $name);
     if ($direction) {
         $this->test($name, $direction);
     } else {
         $this->test($name, Direction::up());
         $this->test($name, Direction::down());
     }
 }
 /**
  * Test to ensure up static method return an instance of Direction with 'up' direction.
  */
 public function testUp()
 {
     $direction = Direction::up();
     $this->assertTrue($direction instanceof Direction);
     $this->assertEquals(DirectionEnum::UP, $direction);
 }