コード例 #1
0
ファイル: MigrateUpCommand.php プロジェクト: wandu/framework
 public function execute()
 {
     $id = $this->input->getArgument('id');
     try {
         $this->manager->up($id);
     } catch (RuntimeException $e) {
         throw new ConsoleException("<error>Error</error> {$e->getMessage()}");
     }
     $this->output->writeln("<info>migrate</info> {$id}");
 }
コード例 #2
0
 public function execute()
 {
     $this->output->writeln(' STATUS   MIGRATION ID   MIGRATION NAME');
     $this->output->writeln('----------------------------------------');
     foreach ($this->manager->getMigrations() as $migration) {
         if ($migration->isApplied()) {
             $textFormat = " <info>%6s</info>   %s  <comment>%s</comment>";
         } else {
             $textFormat = " <error>%6s</error>   %s  <comment>%s</comment>";
         }
         $this->output->writeln(sprintf($textFormat, $migration->isApplied() ? 'up  ' : 'down ', $migration->getId(), $migration->getName()));
     }
 }
コード例 #3
0
ファイル: MigrateCommand.php プロジェクト: wandu/framework
 public function execute()
 {
     $migrations = $this->manager->getMigrations();
     $isNoMigration = true;
     foreach ($migrations as $migration) {
         if (!$migration->isApplied()) {
             $isNoMigration = false;
             $migration->up();
             $this->output->writeln(sprintf("<info>migrate</info> %s", $migration->getId()));
         }
     }
     if ($isNoMigration) {
         $this->output->writeln("<comment>there is no migration to migrate.</comment>");
     }
 }
コード例 #4
0
 public function execute()
 {
     $untilMigrationId = $this->input->getArgument('until');
     /** @var \Wandu\Database\Migrator\MigrationContainer[] $migrations */
     $migrations = array_reverse($this->manager->getMigrations());
     if (!count($migrations)) {
         $this->output->writeln("<comment>there is no migration to rollback.</comment>");
         return 2;
     }
     foreach ($migrations as $migration) {
         if (!$migration->isApplied()) {
             continue;
         }
         $this->manager->down($migration->getId());
         if ($migration->getId() === $untilMigrationId || !$untilMigrationId) {
             break;
         }
     }
 }