public function getFormattedMigrationStatus($showMigrations = false, $showDescriptions = false)
    {
        $statusInformation = $this->getMigrationStatus();
        $output = PHP_EOL . '<info>==</info> Configuration' . PHP_EOL;

        foreach ($statusInformation as $name => $value) {
            if ($name == 'New Migrations') {
                $value = $value > 0 ? '<question>' . $value . '</question>' : 0;
            }
            if ($name == 'Executed Unavailable Migrations') {
                $value = $value > 0 ? '<error>' . $value . '</error>' : 0;
            }
            $output .= '   <comment>></comment> ' . $name . ': ' . str_repeat(' ', 35 - strlen($name)) . $value . PHP_EOL;
        }

        if ($showMigrations) {
            $configuration = $this->getMigrationConfiguration();

            $executedMigrations = $configuration->getMigratedVersions();
            $availableMigrations = $configuration->getAvailableVersions();
            $executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
            if ($migrations = $configuration->getMigrations()) {
                $docCommentParser = new DocCommentParser();

                $output .= PHP_EOL . ' <info>==</info> Available Migration Versions' . PHP_EOL;

                /** @var Version $version */
                foreach ($migrations as $version) {
                    $packageKey = $this->getPackageKeyFromMigrationVersion($version);
                    $croppedPackageKey = strlen($packageKey) < 30 ? $packageKey : substr($packageKey, 0, 29) . '~';
                    $packageKeyColumn = ' ' . str_pad($croppedPackageKey, 30, ' ');
                    $isMigrated = in_array($version->getVersion(), $executedMigrations);
                    $status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>';
                    $migrationDescription = '';
                    if ($showDescriptions) {
                        $migrationDescription = str_repeat(' ', 2) . $this->getMigrationDescription($version, $docCommentParser);
                    }
                    $formattedVersion = $configuration->getDateTime($version->getVersion());

                    $output .= '    <comment>></comment> ' . $formattedVersion .
                        ' (<comment>' . $version->getVersion() . '</comment>)' . $packageKeyColumn .
                        str_repeat(' ', 2) . $status . $migrationDescription . PHP_EOL;
                }
            }

            if (count($executedUnavailableMigrations)) {
                $output .= PHP_EOL . ' <info>==</info> Previously Executed Unavailable Migration Versions' . PHP_EOL;
                foreach ($executedUnavailableMigrations as $executedUnavailableMigration) {
                    $output .= '    <comment>></comment> ' . $configuration->getDateTime($executedUnavailableMigration) .
                        ' (<comment>' . $executedUnavailableMigration . '</comment>)' . PHP_EOL;
                }
            }
        }

        return $output;
    }
public function getFormattedMigrationStatus($showMigrations = false, $showDescriptions = false)
    {
        $statusInformation = $this->getMigrationStatus();
        $output = PHP_EOL . '<info>==</info> Configuration' . PHP_EOL;

        foreach ($statusInformation as $name => $value) {
            if ($name == 'New Migrations') {
                $value = $value > 0 ? '<question>' . $value . '</question>' : 0;
            }
            if ($name == 'Executed Unavailable Migrations') {
                $value = $value > 0 ? '<error>' . $value . '</error>' : 0;
            }
            $output .= '   <comment>></comment> ' . $name . ': ' . str_repeat(' ', 35 - strlen($name)) . $value . PHP_EOL;
        }

        if ($showMigrations) {
            $configuration = $this->getMigrationConfiguration();

            $executedMigrations = $configuration->getMigratedVersions();
            $availableMigrations = $configuration->getAvailableVersions();
            $executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
            if ($migrations = $configuration->getMigrations()) {
                $docCommentParser = new DocCommentParser();

                $output .= PHP_EOL . ' <info>==</info> Available Migration Versions' . PHP_EOL;

                /** @var Version $version */
                foreach ($migrations as $version) {
                    $packageKey = $this->getPackageKeyFromMigrationVersion($version);
                    $croppedPackageKey = strlen($packageKey) < 30 ? $packageKey : substr($packageKey, 0, 29) . '~';
                    $packageKeyColumn = ' ' . str_pad($croppedPackageKey, 30, ' ');
                    $isMigrated = in_array($version->getVersion(), $executedMigrations);
                    $status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>';
                    $migrationDescription = '';
                    if ($showDescriptions) {
                        $migrationDescription = str_repeat(' ', 2) . $this->getMigrationDescription($version, $docCommentParser);
                    }
                    $formattedVersion = $configuration->getDateTime($version->getVersion());

                    $output .= '    <comment>></comment> ' . $formattedVersion .
                        ' (<comment>' . $version->getVersion() . '</comment>)' . $packageKeyColumn .
                        str_repeat(' ', 2) . $status . $migrationDescription . PHP_EOL;
                }
            }

            if (count($executedUnavailableMigrations)) {
                $output .= PHP_EOL . ' <info>==</info> Previously Executed Unavailable Migration Versions' . PHP_EOL;
                foreach ($executedUnavailableMigrations as $executedUnavailableMigration) {
                    $output .= '    <comment>></comment> ' . $configuration->getDateTime($executedUnavailableMigration) .
                        ' (<comment>' . $executedUnavailableMigration . '</comment>)' . PHP_EOL;
                }
            }
        }

        return $output;
    }
public function getFormattedMigrationStatus ( $ showMigrations = false , $ showDescriptions = false ) { $ statusInformation = $ this -> getMigrationStatus ( ) ; $ output = PHP_EOL . '<info>==</info> Configuration' . PHP_EOL ; foreach ( $ statusInformation as $ name => $ value ) { if ( $ name == 'New Migrations' ) { $ value = $ value > 0 ? '<question>' . $ value . '</question>' : 0 ; } if ( $ name == 'Executed Unavailable Migrations' ) { $ value = $ value > 0 ? '<error>' . $ value . '</error>' : 0 ; } $ output .= '   <comment>></comment> ' . $ name . ': ' . str_repeat ( ' ' , 35 - strlen ( $ name ) ) . $ value . PHP_EOL ; } if ( $ showMigrations ) { $ configuration = $ this -> getMigrationConfiguration ( ) ; $ executedMigrations = $ configuration -> getMigratedVersions ( ) ; $ availableMigrations = $ configuration -> getAvailableVersions ( ) ; $ executedUnavailableMigrations = array_diff ( $ executedMigrations , $ availableMigrations ) ; if ( $ migrations = $ configuration -> getMigrations ( ) ) { $ docCommentParser = new DocCommentParser ( ) ; $ output .= PHP_EOL . ' <info>==</info> Available Migration Versions' . PHP_EOL ; /** @var Version $version */ foreach ( $ migrations as $ version ) { $ packageKey = $ this -> getPackageKeyFromMigrationVersion ( $ version ) ; $ croppedPackageKey = strlen ( $ packageKey ) < 30 ? $ packageKey : substr ( $ packageKey , 0 , 29 ) . '~' ; $ packageKeyColumn = ' ' . str_pad ( $ croppedPackageKey , 30 , ' ' ) ; $ isMigrated = in_array ( $ version -> getVersion ( ) , $ executedMigrations ) ; $ status = $ isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>' ; $ migrationDescription = '' ; if ( $ showDescriptions ) { $ migrationDescription = str_repeat ( ' ' , 2 ) . $ this -> getMigrationDescription ( $ version , $ docCommentParser ) ; } $ formattedVersion = $ configuration -> getDateTime ( $ version -> getVersion ( ) ) ; $ output .= '    <comment>></comment> ' . $ formattedVersion . ' (<comment>' . $ version -> getVersion ( ) . '</comment>)' . $ packageKeyColumn . str_repeat ( ' ' , 2 ) . $ status . $ migrationDescription . PHP_EOL ; } } if ( count ( $ executedUnavailableMigrations ) ) { $ output .= PHP_EOL . ' <info>==</info> Previously Executed Unavailable Migration Versions' . PHP_EOL ; foreach ( $ executedUnavailableMigrations as $ executedUnavailableMigration ) { $ output .= '    <comment>></comment> ' . $ configuration -> getDateTime ( $ executedUnavailableMigration ) . ' (<comment>' . $ executedUnavailableMigration . '</comment>)' . PHP_EOL ; } } } return $ output ; }
Returns a formatted string of current database migration status.

@param boolean $showMigrations
@param boolean $showDescriptions
@return string
@throws \ReflectionException
@throws DBALException
Returns a formatted string of current database migration status .