Skip to content

Commit 18bd972

Browse files
committed
Updated commands
1 parent f0b2c53 commit 18bd972

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

Command/MigrateCommand.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class MigrateCommand extends Command
2727
{
2828
private $factory;
2929
private $container;
30+
private $actions = array(
31+
'up', 'down', 'top', 'bottom',
32+
);
3033

3134
public function __construct(
3235
MigratorFactory $factory,
@@ -41,8 +44,35 @@ public function __construct(
4144
public function configure()
4245
{
4346
$this->setName('phpcr:migrations:migrate');
44-
$this->addArgument('to', InputArgument::OPTIONAL, 'Migrate to this version');
47+
$this->addArgument('to', InputArgument::OPTIONAL, sprintf(
48+
'Version name to migrate to, or an action: "<comment>%s</comment>"',
49+
implode('</comment>", "<comment>', $this->actions)
50+
));
4551
$this->setDescription('Migrate the content repository between versions');
52+
$this->setHelp(<<<EOT
53+
Migrate to a specific version or perform an action.
54+
55+
By default it will migrate to the latest version:
56+
57+
$ %command.full_name%
58+
59+
You can migrate to a specific version (either in the "past" or "future"):
60+
61+
$ %command.full_name% 201504011200
62+
63+
Or specify an action
64+
65+
$ %command.full_name% <action>
66+
67+
Action can be one of:
68+
69+
- <comment>up</comment>: Migrate one version up
70+
- <comment>down</comment>: Migrate one version down
71+
- <comment>top</comment>: Migrate to the latest version
72+
- <comment>bottom</comment>: Revert all migrations
73+
74+
EOT
75+
);
4676
}
4777

4878
public function execute(InputInterface $input, OutputInterface $output)

Command/StatusCommand.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ public function configure()
3636
{
3737
$this->setName('phpcr:migrations:status');
3838
$this->setDescription('Show the current migration status');
39+
$this->setHelp(<<<EOT
40+
Display a table which displays all available migrations and whether they have been migrated or not:
41+
42+
- <info>Version</info>: Name of the migration version
43+
- <info>Date</info>: Date that the migration was <comment>created</comment>
44+
- <info>Migrated</info>: Date that the migration was <comment>executed</comment> or <comment>n/a</comment>
45+
- <info>Path</info>: Path to the migration file
46+
47+
EOT
48+
);
3949
}
4050

4151
public function execute(InputInterface $input, OutputInterface $output)
@@ -55,7 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output)
5565
$versionName == $currentVersion ? '*' : '',
5666
$versionName,
5767
$this->getDate($versionName),
58-
in_array($versionName, $executedVersions) ? '<info>YES</info>' : '<comment>NO</comment>',
68+
isset($executedVersions[$versionName]) ? '<info>' . $executedVersions[$versionName]['executed']->format('Y-m-d H:i:s') . '</info>' : 'n/a',
5969
substr($reflection->getFileName(), strlen(getcwd()) + 1),
6070
));
6171
}
@@ -71,7 +81,7 @@ public function execute(InputInterface $input, OutputInterface $output)
7181

7282
private function getDate($versionName)
7383
{
74-
return date('Y-m-d H:i', strtotime(substr($versionName, 1)));
84+
return date('Y-m-d H:i', strtotime($versionName));
7585
}
7686
}
7787

0 commit comments

Comments
 (0)