Cleanup migrations.

@option string migrations
Optional list of migrations to reset, separated by commmas.
511691
public function migrateCleanup($opts = ['migrations' => '']) {
    if ($opts['migrations'] && ($this->migrationSourceFolder() || $this->usesMigrationPlugins)) {
      $migrations = explode(',', $opts['migrations']);
      $project_properties = $this->getProjectProperties();

      foreach ($migrations as $migration) {
        $this->taskExec('drush mrs ' . $migration)
          ->dir($project_properties['web_root'])
          ->run();
      }
    }
    if ($this->migrationSourceFolder()) {
      $this->taskExec('drush mr --all && drush cim --partial --source=' . $this->migrationSourceFolder() . ' -y && drush ms')
        ->dir($project_properties['web_root'])
        ->run();
    }
    else if ($this->usesMigrationPlugins) {
      $this->taskExec('drush cr && drush mr --all && drush ms')
        ->dir($project_properties['web_root'])
        ->run();
    }
    else {
      $this->say('No migration sources configured.');
      $this->say('To use this command, you must either return a folder path from the migrationSourceFolder() method or set $usesMigrationPlugins to TRUE in your project\'s RoboFile.php.');
      return FALSE;
    }
  }
488285
public function clean()
    {
        $jobFiles = glob($this->getLocation() . '*.js');
        foreach ($jobFiles as $file) {
            unlink($file);
        }
    }
671638
public function clean() : void
    {
        foreach ($this->retrieveAllKeys() as $k) {
            $this->remove((string)$k);
        }
    }
1185791
public function cleanup()
  {
    // Has to be done, otherwise sqlite-file is locked on Windows-OS
    $this->PDO = null;
    $this->PreparedInsertStatement = null;

    unlink($this->sqlite_db_file);
  }
568710
protected function cleanVendorMigrationsFolders()
    {
        if( env( 'ENSPHERE_IMPORT', false ) ) {
            $this->info( 'vendor migration clean skipped...' );
            return;
        }

        if( ! file_exists( base_path( 'database/migrations/vendor/' ) ) ) {
            $this->info( base_path( 'database/migrations/vendor/' ) . ' doesn\'t exist...' );
            return;
        }

        $di = new \RecursiveDirectoryIterator( base_path( 'database/migrations/vendor/' ), \FilesystemIterator::SKIP_DOTS );
        $ri = new \RecursiveIteratorIterator( $di, \RecursiveIteratorIterator::CHILD_FIRST );
        foreach ( $ri as $file ) {
            $file->isDir() ?  rmdir( $file ) : unlink( $file );
        }
        $this->info( 'vendor migration files cleaned...' );
    }
836664
private function migrate()
    {
        $action = $this->arg->getParameter('action');

        if (!is_null($action)) {
            $this->throwFailsCommand('This action is not allow!', 'help migration');
        }

        $this->command->call(
            'migrate',
            'migration',
            null
        );
    }
1099876
protected function resetPackages() {
        foreach($this->options as $op=>$junk){
            if(preg_match("#PackageList#",$op)){
                unset($this->options[$op]);
            }
        }
    }
998386
private function cleanupSlaveConnections()
    {
        foreach ($this->config['database']['connections'] as $name => $connection) {
            if (count($connection['slaves']) <= 0) {
                unset($this->config['database']['connections'][$name]['slaves']);
            }
        }
    }
974230
public function cleanUp()
    {
        $composerBinDirectory = $this->configuration->getComposerBinDirectory();

        if (false === is_dir($composerBinDirectory)) {
            $this->helper->getFilesystem()->createDirectory($composerBinDirectory);
        }

        $this->removeFromDir($composerBinDirectory);
        $this->removeFromDir(
            $this->configuration->getBinDirectory(),
            array_keys($this->configuration->getTools())
        );
    }
28493
public function cleanup()
	{
		$this->log('cleanup', LOG_DEBUG);

		$past_deployments = array();

		if (is_array($this->remote_host))
		{
			foreach ($this->remote_host as $remote_host)
			{
				if ($past_dirs = $this->collectPastDeployments($remote_host, $this->remote_dir))
				{
					$past_deployments[] = array(
						'remote_host' => $remote_host,
						'remote_dir' => $this->remote_dir,
						'dirs' => $past_dirs
					);
				}
			}
		}
		else
		{
			if ($past_dirs = $this->collectPastDeployments($this->remote_host, $this->remote_dir))
			{
				$past_deployments[] = array(
					'remote_host' => $this->remote_host,
					'remote_dir' => $this->remote_dir,
					'dirs' => $past_dirs
				);
			}
		}

		if (!empty($past_deployments)) {
			if (static::inputPrompt('Delete old directories? (yes/no): ', 'no') == 'yes')
				$this->deletePastDeployments($past_deployments);
		}
		else {
			$this->log('No cleanup needed');
		}
	}
956222
private function migration()
    {
        $action = $this->arg->getParameter('action');

        if (!in_array($action, ['migrate', 'rollback', 'reset'])) {
            $this->throwFailsCommand('This action is not exists!', 'help migration');
        }

        $target = $this->arg->getParameter('target');

        $this->command->call(
            $action,
            'migration',
            $target
        );
    }
32108
private List<MigrationInfo> resolved(MigrationInfo[] migrationInfos) {
        if (migrationInfos.length == 0)
            throw new NotFoundException();
        List<MigrationInfo> resolvedMigrations = Lists.newArrayList();
        for (MigrationInfo migrationInfo : migrationInfos) {
            if (migrationInfo.getState().isResolved()) {
                resolvedMigrations.add(migrationInfo);
            }
        }

        return resolvedMigrations;
    }
593067
def _cleanup(self):
        '''
        
        '''
        self._declare_cb = None
        self._delete_cb = None
        super(ExchangeClass, self)._cleanup()
1303605
def _cleanup(self, domains):
        """"""
        for option in domains.values():
            try:
                os.remove(option['pot'])
            except (IOError, OSError):
                # It is not a problem if we can't actually remove the temporary file
                pass
786055
private function cleanup()
	{
		foreach ($this->installationMap as $path => $packages) {
			if ($path == '__CHECKSUMS__') {
				continue;
			}

			if (count($packages)) {
				sort($this->installationMap[$path]);
				continue;
			}

			$installation_path = ltrim($path, '/\\' . DIRECTORY_SEPARATOR);
			$installation_path = getcwd() . DIRECTORY_SEPARATOR . $installation_path;

			if (is_dir($installation_path)) {

				//
				// Here's what to do with a directory
				//

				$children = array_merge(
					glob($installation_path . DIRECTORY_SEPARATOR . '/*'),
					glob($installation_path . DIRECTORY_SEPARATOR . '/.*')
				);

				//
				// Children should be at least two (one entry for current dir and another)
				// for parent dir.  Our install map is sorted by the length of the path
				// so we should only be trying to remove directories which have already had
				// other opus related/created children removed.
				//

				if (count($children) > 2) {
					continue;
				}

				if (!@rmdir($installation_path)) {
					switch ($this->integrity) {
						case 'low':
							break;

						case 'medium':
							$this->io->write(sprintf(
								self::TAB . 'Warning: unable to remove empty directory %s',
								$path
							));
							break;

						case 'high':
							throw new \Exception(sprintf(
								'Error removing empty directory %s',
								$path
							));
					}
				}

			} else {

				//
				// Here's what to do with a file
				//

				if (!@unlink($installation_path)) {
					switch ($this->integrity) {
						case 'low':
							break;

						case 'medium':
							$this->io->write(sprintf(
								self::TAB . 'Warning: unable to remove unused file %s; remove manually',
								$path
							));
							break;

						case 'high':
							throw new \Exception(sprintf(
								'Error removing unused file %s, restore file or check permissions and try again',
								$path
							));
					}
				}
			}

			unset($this->installationMap[$path]);
			unset($this->installationMap['__CHECKSUMS__'][$path]);
		}

		//
		// Sort our paths by length
		//

		uksort($this->installationMap, function($a, $b) {
			if (strlen($a) == strlen($b)) {
				return 0;
			}

			if (strlen($a) > strlen($b)) {
				return -1;
			}

			return 1;
		});
	}
697109
def _cleanup(self):
        '''
        
        '''
        if (hasattr(self, 'config')
           and self.config.get('support_archive')
           and os.path.exists(self.config['support_archive'])):
            self.out.warning('Terminated earlier, cleaning up')
            try:
                os.unlink(self.config['support_archive'])
            except Exception as err:
                log.debug(err)
                self.out.error('{} while cleaning up.'.format(err))
997018
def down(self, migration_id):
        """"""
        if not self.check_directory():
            return

        for migration in self.get_migrations_to_down(migration_id):
            logger.info('Rollback migration %s' % migration.filename)

            migration_module = self.load_migration_file(migration.filename)
            if hasattr(migration_module, 'down'):
                migration_module.down(self.db)
            else:
                logger.info('No down method on %s' % migration.filename)

            self.collection.remove({'filename': migration.filename})