def set_migration_started(domain, slug, dry_run=False): progress, _ = DomainMigrationProgress.objects.get_or_create( domain=domain, migration_slug=slug) if progress.migration_status == MigrationStatus.NOT_STARTED: progress.migration_status = MigrationStatus.DRY_RUN if dry_run else MigrationStatus.IN_PROGRESS progress.save() reset_caches(domain, slug) else: raise DomainMigrationProgressError( 'Cannot start a migration that is already in state {}'.format( progress.migration_status))
def set_migration_not_started(domain, slug): progress, _ = DomainMigrationProgress.objects.get_or_create( domain=domain, migration_slug=slug) if migration_in_progress(domain, slug, True): progress.migration_status = MigrationStatus.NOT_STARTED progress.save() reset_caches(domain, slug) else: raise DomainMigrationProgressError( 'Cannot abort a migration that is in state {}'.format( progress.migration_status))
def set_migration_complete(domain, slug): progress, _ = DomainMigrationProgress.objects.get_or_create( domain=domain, migration_slug=slug) if progress.migration_status == MigrationStatus.DRY_RUN: raise DomainMigrationProgressError( "Cannot complete a migration that is in state dry run") if progress.migration_status != MigrationStatus.COMPLETE: progress.migration_status = MigrationStatus.COMPLETE progress.save() reset_caches(domain, slug)