From 69eb3e9ff388778abc7355e7fea6c5a63f4af7b3 Mon Sep 17 00:00:00 2001 From: ngyuki Date: Sat, 2 Sep 2017 22:20:47 +0900 Subject: [PATCH] =?UTF-8?q?redo=20=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ src/Command/RedoCommand.php | 21 +++++++++++++++++++++ src/Console/Application.php | 1 + 3 files changed, 32 insertions(+) create mode 100644 src/Command/RedoCommand.php diff --git a/README.md b/README.md index 77b5d6e..56f53ba 100644 --- a/README.md +++ b/README.md @@ -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` マイグレーションが適用済であるとマークします。引数としてスクリプトのファイル名を指定します。 diff --git a/src/Command/RedoCommand.php b/src/Command/RedoCommand.php new file mode 100644 index 0000000..0c8668f --- /dev/null +++ b/src/Command/RedoCommand.php @@ -0,0 +1,21 @@ +setName('redo')->setDescription('down/up one version'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->migrator->down(); + $this->migrator->up(); + } +} diff --git a/src/Console/Application.php b/src/Console/Application.php index dec95bd..98079ee 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -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();