protected function doRefresh(Migrator $migrator)
    {
        // retreive installed versions
        $installed_migrations = $migrator->installedMigrationsByDesc();

        // downgrade
        foreach ($installed_migrations as $group => $migrations) {
            foreach ($migrations as $data) {
                $this->infoDowngrade($group, $data->version, $data->class);

                $migrator->doDowngrade($group, $data->version);
            }
        }

        // upgrade
        foreach ($migrator->migrationGroups() as $group) {
            foreach ($migrator->migrationVersions($group) as $version => $class) {
                $this->infoUpgrade($group, $version, $class);

                $migrator->doUpgrade($group, $version, $class);
            }
        }
    }