Rollback a migration
341137
def rollback_migration(engine, connection, path, migration_to_rollback):
    

    # Get migrations applied
    migrations_applied = get_migrations_applied(engine, connection)

    # Ensure that the migration was previously applied
    if not is_applied(migrations_applied, migration_to_rollback):
        raise RuntimeError(
            '`%s` is not in the list of previously applied migrations.' % (migration_to_rollback))

    # Rollback file
    file = path + migration_to_rollback + '/down.sql'

    # Ensure that the file exists
    check_exists(file)

    # Set vars
    basename = os.path.basename(os.path.dirname(file))

    # Get migration source
    source = get_migration_source(file)
    # print (source);

    # Run migration rollback
    run_migration(connection, source, engine)

    # Delete migration
    delete_migration(connection, basename)

    # Log
    print('   -> Migration `%s` has been rolled back' % (basename))

    return True
168292
protected function rollback()
    {
        if (!$this->isUpdate() || ($this->isUpdate() && $this->renamed)) {
            gplcart_file_delete_recursive($this->destination);
        }

        if (isset($this->tempname)) {
            rename($this->tempname, $this->destination);
        }
    }
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})
1138237
def rollback(using=None):
    
    if using is None:
        for using in tldap.backend.connections:
            connection = tldap.backend.connections[using]
            connection.rollback()
        return
    connection = tldap.backend.connections[using]
    connection.rollback()
1350781
def rollback(self):
        
        if self.changed:
            rollback_cmd = '<load><config><from>{0}</from></config></load>'.format(self.backup_file)
            self.device.op(cmd=rollback_cmd)
            time.sleep(5)

            if self.ssh_connection is False:
                self._open_ssh()
            try:
                self.ssh_device.commit()
                self.loaded = False
                self.changed = False
                self.merge_config = False
            except:    # noqa
                ReplaceConfigException("Error while loading backup config")
1342212
public function rollback()
    {
        if (!empty($this->transactions)) {
            $t = array_pop($this->transactions);
            $this->data = $t['data'];
            $this->lastAI = $t['lastAI'];
        }
        $this->log('ROLLBACK');
    }
1122706
public function trans_rollback()
    {
        $this->conn(); //connect server
        $this->db->rollback();
        $this->db->autocommit(true);
    }
210767
public function rollback($pretend = false)
	{
		$this->notes = array();

		// We want to pull in the last batch of migrations that ran on the previous
		// migration operation. We'll then reverse those migrations and run each
		// of them "down" to reverse the last migration "operation" which ran.
		$migrations = $this->repository->getLast();

		if (count($migrations) == 0)
		{
			$this->note('<info>Nothing to rollback.</info>');

			return count($migrations);
		}

		// We need to reverse these migrations so that they are "downed" in reverse
		// to what they run on "up". It lets us backtrack through the migrations
		// and properly reverse the entire database schema operation that ran.
		foreach ($migrations as $migration)
		{
			$this->runDown((object) $migration, $pretend);
		}

		return count($migrations);
	}
1205399
protected function _rollBack()
    {
        $this->_connect();
        $this->_connection->rollback();
        $this->_connection->autocommit(true);
    }
435641
def _run_down(self, path, migration, pretend=False):
        
        migration_file = migration['migration']

        instance = self._resolve(path, migration_file)

        if pretend:
            return self._pretend_to_run(instance, 'down')

        instance.down()

        self._repository.delete(migration)

        self._note('<info>✓ Rolled back</info> %s' % migration_file)
113154
def handle(self):
        
        if not self.confirm_to_proceed(
            "<question>Are you sure you want to rollback the last migration?:</question> "
        ):
            return

        database = self.option("database")
        repository = DatabaseMigrationRepository(self.resolver, "migrations")

        migrator = Migrator(repository, self.resolver)

        self._prepare_database(migrator, database)

        pretend = self.option("pretend")

        path = self.option("path")

        if path is None:
            path = self._get_migration_path()

        migrator.rollback(path, pretend)

        for note in migrator.get_notes():
            self.line(note)
14655
def rollback(self):
        """"""
        for p in self._moves:
            logging.info("Moving to %s\n from %s", *p)

        for new_path, path in self._moves:
            try:
                logger.debug('Replacing %s from %s', new_path, path)
                if os.path.isfile(new_path):
                    os.unlink(new_path)
                elif os.path.isdir(new_path):
                    rmtree(new_path)
                renames(path, new_path)
            except OSError as ex:
                logger.error("Failed to restore %s", new_path)
                logger.debug("Exception: %s", ex)

        self.commit()
1049088
def reset(self, path, pretend=False):
        
        self._notes = []

        migrations = sorted(self._repository.get_ran(), reverse=True)

        count = len(migrations)

        if count == 0:
            self._note("<info>Nothing to rollback.</info>")
        else:
            for migration in migrations:
                self._run_down(path, {"migration": migration}, pretend)

        return count
102907
def runSql(self, migrationName, version):
        
        sys.stdout.write("Running migration %s to version %s: ..."%(migrationName, version))
        sqlPath = os.path.join(self.migrationDirectory, migrationName)
        sql = open(sqlPath, "r").read()
        try:
            if self.session.is_active:
                print "session is active"
                self.session.commit()
            self.session.begin()
            executeBatch(self.session, sql)
            self.session.add(models.Migration(version, migrationName))
        except:
            print "\n"
            self.session.rollback()
            raise
        else:
            self.session.commit()
        sys.stdout.write("\r")
        sys.stdout.flush()
        sys.stdout.write("Running migration %s to version %s: SUCCESS!\n"%(migrationName, version))
1022756
function rollback(client, done, error, callback) {
  client.query('ROLLBACK', rollbackError => {
    done(rollbackError);
    return callback(rollbackError || error, null);
  });
}
1139229
function rollback(newVersion) {
  if (strategy === 'stable') {
    // reset master
    shell.exec('git reset --hard origin/master');
    shell.exec('git checkout develop');
  } else {
    // remove last commit
    shell.exec('git reset --hard HEAD~1');
  }

  // remove local created tag
  shell.exec(`git tag -d v${newVersion}`);
  process.exit(1);
}
401369
def migrate(app_name=None, revision=None):
    ""
    cmd = ['python bin/manage.py syncdb --migrate']
    if app_name:
        cmd.append(app_name)
        if revision:
            cmd.append(revision)
    verun(' '.join(cmd))