public function actionPartialDown($version)
    {
        $migrations = $this->getVersions('history', $version);
        if (empty($migrations)) {
            $this->stdout("No migration has been done before.\n", Console::FG_GREEN);
            return self::EXIT_CODE_NORMAL;
        }
        $n = count($migrations);
        $this->stdout("Total $n new " . ($n === 1 ? 'migration' : 'migrations') . " to be referted:\n", Console::FG_YELLOW);

        foreach ($migrations as $migration) {
            $this->stdout("\t$migration\n");
        }
        $this->stdout("\n");

        $reverted = 0;
        if ($this->confirm('Revert the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) {
            foreach ($migrations as $migration) {
                if (!$this->migrateDown($migration)) {
                    $this->stdout("\n$reverted from $n " . ($reverted === 1 ? 'migration was' : 'migrations were') . " reverted.\n", Console::FG_RED);
                    $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED);

                    return self::EXIT_CODE_ERROR;
                }
                $reverted++;
            }
            $this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') . " reverted.\n", Console::FG_GREEN);
            $this->stdout("\nMigrated down successfully.\n", Console::FG_GREEN);
        }
    }
public function actionPartialDown($version)
    {
        $migrations = $this->getVersions('history', $version);
        if (empty($migrations)) {
            $this->stdout("No migration has been done before.\n", Console::FG_GREEN);
            return self::EXIT_CODE_NORMAL;
        }
        $n = count($migrations);
        $this->stdout("Total $n new " . ($n === 1 ? 'migration' : 'migrations') . " to be referted:\n", Console::FG_YELLOW);

        foreach ($migrations as $migration) {
            $this->stdout("\t$migration\n");
        }
        $this->stdout("\n");

        $reverted = 0;
        if ($this->confirm('Revert the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) {
            foreach ($migrations as $migration) {
                if (!$this->migrateDown($migration)) {
                    $this->stdout("\n$reverted from $n " . ($reverted === 1 ? 'migration was' : 'migrations were') . " reverted.\n", Console::FG_RED);
                    $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED);

                    return self::EXIT_CODE_ERROR;
                }
                $reverted++;
            }
            $this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') . " reverted.\n", Console::FG_GREEN);
            $this->stdout("\nMigrated down successfully.\n", Console::FG_GREEN);
        }
    }
public function actionPartialDown ( $ version ) { $ migrations = $ this -> getVersions ( 'history' , $ version ) ; if ( empty ( $ migrations ) ) { $ this -> stdout ( "No migration has been done before.\n" , Console :: FG_GREEN ) ; return self :: EXIT_CODE_NORMAL ; } $ n = count ( $ migrations ) ; $ this -> stdout ( "Total $n new " . ( $ n === 1 ? 'migration' : 'migrations' ) . " to be referted:\n" , Console :: FG_YELLOW ) ; foreach ( $ migrations as $ migration ) { $ this -> stdout ( "\t$migration\n" ) ; } $ this -> stdout ( "\n" ) ; $ reverted = 0 ; if ( $ this -> confirm ( 'Revert the above ' . ( $ n === 1 ? 'migration' : 'migrations' ) . '?' ) ) { foreach ( $ migrations as $ migration ) { if ( ! $ this -> migrateDown ( $ migration ) ) { $ this -> stdout ( "\n$reverted from $n " . ( $ reverted === 1 ? 'migration was' : 'migrations were' ) . " reverted.\n" , Console :: FG_RED ) ; $ this -> stdout ( "\nMigration failed. The rest of the migrations are canceled.\n" , Console :: FG_RED ) ; return self :: EXIT_CODE_ERROR ; } $ reverted ++ ; } $ this -> stdout ( "\n$n " . ( $ n === 1 ? 'migration was' : 'migrations were' ) . " reverted.\n" , Console :: FG_GREEN ) ; $ this -> stdout ( "\nMigrated down successfully.\n" , Console :: FG_GREEN ) ; } }
Downgrades the application by reverting old migration.
For example,

```
yii migrate/partial-down 101129_185401                      # using timestamp
yii migrate/partial-down m101129_185401_create_user_table   # using full name
```

@param string $version the version at which the migration history should be marked.
This can be either the timestamp or the full name of the migration.
@return int CLI exit code
@throws Exception if the version argument is invalid or the version cannot be found.
Downgrades the application by reverting old migration . For example