| @@ 11-39 (lines=29) @@ | ||
| 8 | ||
| 9 | use Dami\Cli\Command\MigrateCommand as DamiMigrateCommand; |
|
| 10 | ||
| 11 | class MigrateCommand extends AbstractCommand |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * {@inheritdoc} |
|
| 15 | */ |
|
| 16 | protected function configure() |
|
| 17 | { |
|
| 18 | $this |
|
| 19 | ->setName('dami:migrate') |
|
| 20 | ->setDescription('Migrate database.') |
|
| 21 | ->addArgument('to-version', InputArgument::OPTIONAL, 'Migrate to specific version of migrations'); |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 28 | { |
|
| 29 | try { |
|
| 30 | $this->prepareMigrationDirectory(); |
|
| 31 | ||
| 32 | $migration = $this->getContainer()->get('dami.migration'); |
|
| 33 | $damiStatusCommand = new DamiMigrateCommand($this->getName(), $this->getContainer()); |
|
| 34 | $damiStatusCommand->execute($input, $output); |
|
| 35 | } catch (\Exception $e) { |
|
| 36 | $output->writeln(sprintf("<error>%s</error>", $e->getMessage())); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 11-39 (lines=29) @@ | ||
| 8 | ||
| 9 | use Dami\Cli\Command\RollbackCommand as DamiRollbackCommand; |
|
| 10 | ||
| 11 | class RollbackCommand extends AbstractCommand |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * {@inheritdoc} |
|
| 15 | */ |
|
| 16 | protected function configure() |
|
| 17 | { |
|
| 18 | $this |
|
| 19 | ->setName('dami:rollback') |
|
| 20 | ->setDescription('Rollback migrations.') |
|
| 21 | ->addArgument('to-version', InputArgument::OPTIONAL, 'Rollback to specific version of migrations'); |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 28 | { |
|
| 29 | try { |
|
| 30 | $this->prepareMigrationDirectory(); |
|
| 31 | ||
| 32 | $migration = $this->getContainer()->get('dami.migration'); |
|
| 33 | $damiStatusCommand = new DamiRollbackCommand($this->getName(), $this->getContainer()); |
|
| 34 | $damiStatusCommand->execute($input, $output); |
|
| 35 | } catch (\Exception $e) { |
|
| 36 | $output->writeln(sprintf("<error>%s</error>", $e->getMessage())); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||