Skip to content

Commit

Permalink
redo コマンドを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
ngyuki committed Sep 2, 2017
1 parent 9527df7 commit 69eb3e9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -157,6 +157,16 @@ $ vendor/bin/db-migrate down
down: 20140829-02.sql
```

### `db-migrate redo`

down -> up を連続して実行します。

```console
$ vendor/bin/db-migrate redo
down: 20140829-02.sql
up: 20140829-02.sql
```

### `db-migrate set`

マイグレーションが適用済であるとマークします。引数としてスクリプトのファイル名を指定します。
Expand Down
21 changes: 21 additions & 0 deletions src/Command/RedoCommand.php
@@ -0,0 +1,21 @@
<?php
namespace ngyuki\DbMigrate\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class RedoCommand extends AbstractCommand
{
protected function configure()
{
parent::configure();

$this->setName('redo')->setDescription('down/up one version');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->migrator->down();
$this->migrator->up();
}
}
1 change: 1 addition & 0 deletions src/Console/Application.php
Expand Up @@ -24,6 +24,7 @@ public function __construct()
$commands[] = new Command\MigrateCommand();
$commands[] = new Command\UpCommand();
$commands[] = new Command\DownCommand();
$commands[] = new Command\RedoCommand();
$commands[] = new Command\StatusCommand();
$commands[] = new Command\SetCommand();
$commands[] = new Command\UnsetCommand();
Expand Down

0 comments on commit 69eb3e9

Please sign in to comment.