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())); } }
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>"); } }
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; } } }