Migrate data objects.

        :param data: Queryset containing all data objects that need
            to be migrated
        :param from_state: Database model state
487091
def migrate_data(self, data, from_state):
        
        for instance in data:
            if instance.status == 'ER':
                continue

            container = getattr(instance, self.schema_type, {})
            schema = container.pop(self.field[-1])
            container[self.new_field] = schema

            setattr(instance, self.schema_type, container)
            instance.save()
1356141
def migrate(engine, database, module, **kwargs):
    '''
    
    '''
    validate_args(engine, database, module)

    options = {
        'direction': kwargs.get('direction', 'up'),
        'fake': kwargs.get('fake', False),
        'force': kwargs.get('force', False),
        'migration': kwargs.get('migration', None),
        'transaction': kwargs.get('transaction', True),
    }

    Migration._meta.database = database
    migrator = DATABASE_MAP[engine](database, module, **options)
    migrator.run()
1023713
def from_dict(cls, database, key, data, clear=False):
        
        hsh = cls(database, key)
        if clear:
            hsh.clear()
        hsh.update(data)
        return hsh
554890
def updateData(self, state_data, action_data, reward_data):
        
#        self.dataLock.acquire()

        self.state_data[:, self.updates] = state_data
        self.action_data[:, self.updates] = action_data
        self.reward_data[0, self.updates] = reward_data
        self.updates += 1
        self._render()
1241401
def check_data(self, data):
        
        data_objs = {
            data_src: data.objects.get(data_src) for data_src in data.layer
        }
        self._is_data_loaded = all(data_objs.values())
        return data_objs
26583
def allow_migrate(self, db, model):
        
        if db != 'old_nodeshot' or model._meta.app_label != 'oldimporter':
            return False
        return True
1201293
def load(self, data):
        
        objs = {}
        for mapper in self.entities:
            objs[mapper.name] = mapper.load(self.loader, data)

        for mapper in self.relations:
            objs[mapper.name] = mapper.load(self.loader, data, objs)
706055
def from_list(cls, database, key, data, clear=False):
        
        arr = cls(database, key)
        if clear:
            arr.clear()
        arr.extend(data)
        return arr
835798
def post_migrate(cls, sender=None, **kwargs):
        
        ContentType = apps.get_model('contenttypes', 'ContentType')

        for model_name, proxy_model in sender.get_proxy_models().items():
            ctype, created = ContentType.objects.get_or_create(app_label=sender.label, model=model_name)
            if created:
                sender.grant_permissions(proxy_model)
443502
def from_data(data):
    
    if len(data) == 0:  # pragma: no cover
        return None
    else:
        ptable = PrettyTable()
        ptable.field_names = data[0].keys()
        for row in data:
            ptable.add_row(row)
        return ptable
530522
def migrate(self, conn):
        
        while self.should_migrate(conn):
            current_version = get_user_version(conn)
            migration = self._get_migration(current_version)
            assert migration.from_ver == current_version
            logger.info(f'Migrating database from {migration.from_ver}'
                        f' to {migration.to_ver}')
            self._migrate_single(conn, migration)
            set_user_version(conn, migration.to_ver)
            logger.info(f'Migrated database to {migration.to_ver}')
1169457
def restore_model(cls, data):
    
    obj = cls()
    for field in data:
        setattr(obj, field, data[field][Field.VALUE])

    return obj
286152
async def create(self, model_, **data):
        
        inst = model_(**data)
        query = model_.insert(**dict(inst.__data__))

        pk = await self.execute(query)
        if inst._pk is None:
            inst._pk = pk
        return inst
255759
def migrate(connection, dsn):
    
    all_migrations = _get_all_migrations()
    logger.debug('Collected migrations: {}'.format(all_migrations))

    for version, modname in all_migrations:
        if _is_missed(connection, version) and version <= SCHEMA_VERSION:
            logger.info('Missed migration: {} migration is missed. Migrating...'.format(version))
            module = __import__(modname, fromlist='dummy')

            # run each migration under its own transaction. This allows us to apply valid migrations
            # and break on invalid.
            trans = connection.begin()
            try:
                module.Migration().migrate(connection)
                _update_version(connection, version)
                trans.commit()
            except:
                trans.rollback()
                logger.error("Failed to migrate '{}'  on {} ".format(version, dsn))
                raise
183223
def from_parse_args(cls, args):
        

        return cls(args.migration_file,
                   args.database,
                   db_user=args.db_user,
                   db_password=args.db_password,
                   db_port=args.db_port,
                   db_host=args.db_host,
                   mode=args.mode,
                   allow_serie=args.allow_serie,
                   force_version=args.force_version,
                   web_host=args.web_host,
                   web_port=args.web_port,
                   web_custom_html=args.web_custom_html,
                   )
788381
def execute(query, data=None):
    
    connection = _State.connection()
    _State.new_transaction()

    if data is None:
        data = []

    result = connection.execute(query, data)

    _State.table = None
    _State.metadata = None
    try:
        del _State.table_pending
    except AttributeError:
        pass

    if not result.returns_rows:
        return {u'data': [], u'keys': []}

    return {u'data': result.fetchall(), u'keys': list(result.keys())}
1363080
def wrap(self, data):
        
        for name, field in self.fields:
            try:
                self._state[name] = field.consume(
                    self._state.get(name, None), data[name])
            except KeyError:
                self._state[name] = None