관리-도구
편집 파일: 096_populate_total_malicious_field.py
def migrate(migrator, database, fake=False, **kwargs): if fake: return MalwareScan = migrator.orm["malware_scans"] MalwareHit = migrator.orm["malware_hits"] for scan in MalwareScan: total_malicious = ( scan.malwarehit_set.select().where(MalwareHit.malicious).count() ) scan.total_malicious = total_malicious scan.save() def rollback(migrator, database, fake=False, **kwargs): pass