Find unregistered migrations.
513900
def get_unregistered_migrations(self):
        """"""
        return [m for m in self.get_migration_files()
                if not self.collection.find_one({'filename': m.filename})]
1305611
def restore_used_registers(self):
        """"""
        used = self.used_registers_stack.pop()
        self.used_registers = used[:]
        used.sort(reverse = True)
        for reg in used:
            self.newline_text("POP \t%s" % SharedData.REGISTERS[reg], True)
            self.free_registers.remove(reg)
1069184
def _get_current_migration_state(self, loader, apps):
        
        # Only care about applied migrations for the passed-in apps.
        apps = set(apps)
        relevant_applied = [migration for migration in loader.applied_migrations if migration[0] in apps]
        # Sort them by the most recent migration and convert to a dictionary,
        # leaving apps as keys and most recent migration as values.
        # NB: this is a dirty trick
        most_recents = dict(sorted(relevant_applied, key=lambda m: m[1]))
        # Fill in the apps with no migrations with 'zero'.
        # NOTE: Unicode Django application names are unsupported.
        most_recents = [[app, 'zero' if app not in most_recents else str(most_recents[app])] for app in apps]
        return most_recents
1057151
protected function getExcludedTables()
	{
		$excludes = ['migrations'];
		$ignore = $this->option('ignore');
		if ( ! empty($ignore)) {
			return array_merge($excludes, explode(',', $ignore));
		}

		return $excludes;
	}
1263728
def get_uncommitted_changes():
    '''
    

    '''
    _required_version = '8.0.0'
    if not __proxy__['panos.is_required_version'](_required_version):
        return False, 'The panos device requires version {0} or greater for this command.'.format(_required_version)

    query = {'type': 'op',
             'cmd': '<show><config><list><changes></changes></list></config></show>'}

    return __proxy__['panos.call'](query)
105662
def check_directory(self):
        """"""
        exists = os.path.exists(self.directory)
        if not exists:
            logger.error("No migrations directory found. Check your path or create a migration first.")
            logger.error("Directory: %s" % self.directory)
        return exists
912024
public function hasMigration()
    {
        $migrations = array_keys($this->getMigrations());
        if (count($migrations)) {
            foreach ($migrations as $version) {
                if (!$this->isMigrated($version)) {
                    return true;
                }
            }
        }

        return false;
    }
1210954
def extract_operations(self, migrations):
        
        operations = []

        for migration in migrations:
            for operation in migration.operations:
                if isinstance(operation, RunSQL):
                    statements = sqlparse.parse(dedent(operation.sql))

                    for statement in statements:
                        operation = SqlObjectOperation.parse(statement)
                        if operation:
                            operations.append(operation)

                            if self.verbosity >= 2:
                                self.stdout.write(" > % -100s (%s)" % (operation, migration))

        return operations
1241464
def cmd_list(self):
        """"""
        from peewee_migrate.router import Router, LOGGER

        LOGGER.setLevel('DEBUG')
        LOGGER.propagate = 0

        router = Router(self.database,
                        migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'],
                        migrate_table=self.app.config['PEEWEE_MIGRATE_TABLE'])

        LOGGER.info('Migrations are done:')
        LOGGER.info('\n'.join(router.done))
        LOGGER.info('')
        LOGGER.info('Migrations are undone:')
        LOGGER.info('\n'.join(router.diff))
560543
def database_current_migration(self):
        
        # If the table doesn't even exist, return None.
        if not self.migration_table.exists(self.session.bind):
            return None

        # Also return None if self.migration_data is None.
        if self.migration_data is None:
            return None

        return self.migration_data.version
697277
def migrateDown(self):
        
        ss = self.avatars.open()
        def _():
            oldAccounts = ss.query(LoginAccount)
            oldMethods = ss.query(LoginMethod)
            for x in list(oldAccounts) + list(oldMethods):
                x.deleteFromStore()
            self.cloneInto(ss, ss)
            IScheduler(ss).migrateDown()
        ss.transact(_)
506373
def find_migrations_directory():
    
    here = os.path.abspath(os.path.dirname(__file__))
    return os.path.join(here, 'sql/migrations')
439649
def list(database=None, directory=None, verbose=None):
    """"""
    router = get_router(directory, database, verbose)
    click.echo('Migrations are done:')
    click.echo('\n'.join(router.done))
    click.echo('')
    click.echo('Migrations are undone:')
    click.echo('\n'.join(router.diff))
1357982
def show_status(self):
        """"""
        if not self.check_directory():
            return

        migrations = self.get_unregistered_migrations()
        if migrations:
            logger.info('Unregistered migrations:')
            for migration in migrations:
                logger.info(migration.filename)
        else:
            logger.info(self.NO_MIGRATIONS_MSG)
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
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})
677495
public function registerMigrations(array $migrations)
    {
        $versions = [];
        foreach ($migrations as $version => $class) {
            $versions[] = $this->registerMigration($version, $class);
        }

        return $versions;
    }