def forwards(self, orm):
        # Note: Don't use "from appname.models import ModelName".
        # Use orm.ModelName to refer to models in this application,
        # and orm['appname.ModelName'] for models in other applications.
        print "Started inserting records in RawDataImageMeta"
        rawdata_all = orm.RawData.objects.filter(event__in=USAGE_EVENTS).values('json', 'id')
        for rawdata in queryset_iterator(rawdata_all):
            notification = self._notification(rawdata['json'])
            orm.RawDataImageMeta.objects.create(
                raw_id=rawdata['id'],
                os_architecture=notification.os_architecture,
                os_distro=notification.os_distro,
                os_version=notification.os_version,
                rax_options=notification.rax_options)
        print "Inserted %s records in RawDataImageMeta" % rawdata_all.count()

        print "\nStarted updating records in InstanceExists"
        exists = orm.InstanceExists.objects.values('raw_id')
        exists_update_count = 0
        for exist in exists:
            image_metadata = orm.RawDataImageMeta.objects.filter(raw_id=exist['raw_id'])
            if image_metadata.count() == 0:
                print "RawDataImageMeta not found for InstanceExists with raw_id %s" % exist['raw_id']
                continue
            orm.InstanceExists.objects.filter(
                raw_id=exist['raw_id']).update(
                    os_architecture=image_metadata[0].os_architecture,
                    os_distro=image_metadata[0].os_distro,
                    os_version=image_metadata[0].os_version,
                    rax_options=image_metadata[0].rax_options)
            exists_update_count += 1
        print "Updated %s records in InstanceExists" % exists_update_count

        print "\nStarted updating records in InstanceUsages"
        usages = orm.InstanceUsage.objects.all().values('request_id')
        usages_update_count = 0
        for usage in usages:
            raw_id = self._find_latest_usage_related_raw_id_for_request_id(orm, usage['request_id'])
            if not raw_id:
                print "No Rawdata entry found for a usage related event with request_id %s" % usage['request_id']
                continue
            image_metadata = orm.RawDataImageMeta.objects.filter(raw_id=raw_id)[0]
            orm.InstanceUsage.objects.filter(
                request_id=usage['request_id']).update(
                    os_architecture=image_metadata.os_architecture,
                    os_distro=image_metadata.os_distro,
                    os_version=image_metadata.os_version,
                    rax_options=image_metadata.rax_options)
            usages_update_count += 1
        print "Updated %s records in InstanceUsages" % usages_update_count
dataset/ETHPy150Open openstack/stacktach/stacktach/migrations/0003_populate_usage_related_fields_in_rawdataimagemeta_instanceexists_and_instanceusages_from_rawdata.py/Migration.forwards/original