Rollback migration
188489
public function down()
    {
        if (Schema::hasTable('lovata_buddies_users') && Schema::hasColumn('lovata_buddies_users', 'active_currency_code')) {
            Schema::table('lovata_buddies_users', function (Blueprint $obTable) {
                $obTable->dropColumn(['active_currency_code']);
            });
        }

        if (Schema::hasTable('users') && Schema::hasColumn('users', 'active_currency_code')) {
            Schema::table('users', function (Blueprint $obTable) {
                $obTable->dropColumn(['active_currency_code']);
            });
        }
    }
1263
def run_migration(data, version_start, version_end):
    """"""
    items = []
    if version_start == 1 and version_end == 2:
        for item in data['accounts']:
            items.append(v2.upgrade(item))

    if version_start == 2 and version_end == 1:
        for item in data:
            items.append(v2.downgrade(item))
        items = {'accounts': items}
    return items
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);
}
1367035
protected function rollbackTransaction()
    {
        $this->entityManager->rollback();

        $connection = $this->entityManager->getConnection();
        if (!$connection->isTransactionActive() || $connection->isRollbackOnly()) {
            $this->entityManager->close();
        }
    }
502514
protected function rollback()
    {
        $transaction = array_pop($this->_transaction);
        if ($transaction && $transaction instanceof Transaction) {
            $transaction->rollBack();
        }
    }
133510
public function rollback()
    {
        if (!Scaffoldinterface::all()->count()) {
            Session::flash('status', 'Nothing To Rollback');

            return redirect('scaffold');
        }

        try {
            Artisan::call('migrate:rollback');
        } catch (\Exception $e) {
            return $e->getMessage();
        }
        $Msg = str_replace("\n", '', Artisan::output());
        Session::flash('status', $Msg);

        return redirect('scaffold');
    }
364271
func (m *Migrate) RollbackMigration(mig *Migration) error {
	if mig.Rollback == nil {
		return ErrRollbackImpossible
	}

	if err := mig.Rollback(m.db); err != nil {
		return err
	}

	sql := fmt.Sprintf("DELETE FROM %s WHERE %s = ?", m.options.TableName, m.options.IDColumnName)
	if _, err := m.db.Exec(sql, mig.ID); err != nil {
		return err
	}
	return nil
}
657705
def merge(self, name='initial'):
        """"""
        migrator = Migrator(self.database)
        migrate = compile_migrations(migrator, self.migrator.orm.values())
        if not migrate:
            return self.logger.error("Can't merge migrations")

        self.clear()

        self.logger.info('Merge migrations into "%s"', name)
        rollback = compile_migrations(self.migrator, [])
        name = self.compile(name, migrate, rollback, 0)

        migrator = Migrator(self.database)
        self.run_one(name, migrator, fake=True, force=True)
        self.logger.info('Migrations has been merged into "%s"', name)
1342212
public function rollback()
    {
        if (!empty($this->transactions)) {
            $t = array_pop($this->transactions);
            $this->data = $t['data'];
            $this->lastAI = $t['lastAI'];
        }
        $this->log('ROLLBACK');
    }
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);
        }
    }
44889
void rollback() {
        if (publishedFullRegistry == null) {
            return;
        }
        writeLock.lock();
        try {
            publishedFullRegistry.readLock.lock();
            try {
                clear(true);
                copy(publishedFullRegistry, this);
                modified = false;
            } finally {
                publishedFullRegistry.readLock.unlock();
            }
        } finally {
            writeLock.unlock();
        }
    }
1296584
def rollback(self):
        """"""
        if self._transaction_nesting_level == 0:
            raise DBALConnectionError.no_active_transaction()

        self.ensure_connected()
        if self._transaction_nesting_level == 1:
            self._transaction_nesting_level = 0
            self._driver.rollback()
            self._is_rollback_only = False
            if not self._auto_commit:
                self.begin_transaction()
        elif self._nest_transactions_with_savepoints:
            self.rollback_savepoint(self._get_nested_transaction_savepoint_name())
            self._transaction_nesting_level -= 1
        else:
            self._is_rollback_only = True
            self._transaction_nesting_level -= 1
1337290
protected function registerRollbackCommand()
    {
        $this->app->singleton('command.migrate.rollback', function ($app) {
            return $this->getCommandWithPackage(new RollbackCommand($app->make('migrator')));
        });
    }
1069307
public function rollback()
    {
        foreach (array_reverse($this->taskHistory) as $historicTask) {
            $historicTask['deployment']->getLogger()->info('Rolling back ' . get_class($historicTask['task']));
            if (!$historicTask['deployment']->isDryRun()) {
                $historicTask['task']->rollback($historicTask['node'], $historicTask['application'], $historicTask['deployment'], $historicTask['options']);
            }
        }
        $this->reset();
    }
808527
async function migrate (direction) {
  let config = require(path.join(process.cwd(), '.', 'config'))
  let db = require(path.join(process.cwd(), '.', 'db'))

  if (direction === 'up') {
    await db.migrate.latest(config.db)
  } else if (direction === 'down') {
    await db.migrate.rollback(config.db)
  } else {
    cli.showHelp(0)
  }

  process.exit(0)
}
994943
def revert(ctx, name, verbose):
    

    try:
        app_name, target_migration = name.split('/', 2)
    except ValueError:
        raise click.ClickException('NAME format is <app>/<migration>')

    apps = ctx.obj['config']['apps']
    if app_name not in apps.keys():
        raise click.ClickException('unknown app "{0}"'.format(app_name))

    app = apps[app_name]
    migrations = app['migrations']
    if target_migration not in migrations:
        raise click.ClickException('unknown migration "{0}"'.format(name))

    mig_idx = migrations.index(target_migration)
    migrations = migrations[-len(migrations) + mig_idx:]  # all migrations after target_migration
    migrations = migrations[::-1]  # in reversed order

    for migration in migrations:
        click.echo(
            click.style('Reverting {0}...'.format(click.style(app_name + '/' + migration, bold=True)), fg='blue'))

        if not ctx.obj['db'].is_migration_applied(app_name, migration):
            click.echo(click.style('  SKIPPED.', fg='green'))
            continue
        try:
            snaql_factory = Snaql(app['path'], '')
            queries = snaql_factory.load_queries(migration + '.revert.sql').ordered_blocks

            for query in queries:
                if verbose:
                    click.echo('    ' + query())

                ctx.obj['db'].query(query())

        except Exception as e:
            click.echo(click.style('  FAILED.', fg='red'))
            ctx.obj['db'].rollback()

            raise click.ClickException('migration execution failed\n{0}'.format(e))

        click.echo(click.style('  OK.', fg='green'))

        ctx.obj['db'].commit()

        ctx.obj['db'].revert_migration(app_name, migration)